I found and successfully used the documentation on how to override an existing model in Sylius, but I was not able to create a completely new one using SyliusResourceBundle. Im guessing this easy if you already know symfony2? I'm still participating, so here is what I have ... what am I missing?
I use the full complete installation of Sylius as my base, so I started here http://sylius.org/blog/simpler-crud-for-symfony2 I have my own "Astound Bundle", settings and several overrides and controllers. I added this to my configuration:
sylius_resource:
resources:
astound.location:
driver: doctrine/orm
templates: AstoundWebBundle:Location
classes:
model: Astound\Bundle\LocationBundle\Model\Location
Then I did:
<?php
namespace Astound\Bundle\LocationBundle\Model;
class Location implements LocationInterface
{
protected $id;
protected $name;
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
}
As well as:
<?php
namespace Astound\Bundle\LocationBundle\Model;
interface LocationInterface
{
public function getId();
public function getName();
public function setName($name);
}
Based on exploring existing models in Sylius and looking at the Doctrine documentation, I did this as well:
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
<mapped-superclass name="Location" table="Locations">
<id name="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="name" type="string" />
</mapped-superclass>
</doctrine-mapping>
, app/console doctrine: schema: update --dump-sql "Locations" , :
- .
app/console: debug,
:
astound.controller.location
Sylius\Bundle\ResourceBundle\Controller\ResourceController
astound.manager.location
n/a doctrine.orm.default_entity_manager
astound.repository.location
Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository
, indexAction . :
astound_location_index:
pattern: /location
methods: [GET]
defaults:
_controller: astound.controller.location:indexAction
, * app_dev.php/Administration/location * , :
"Astound\Bundle\LocationBundle\Model\Location"
, , http://brentertainment.com/other/docs/book/doctrine/orm.html, , php- Entities /: : " "?, Sylius Entity , - ... , Bundle? , Sylius, :
<?php
namespace Astound\Bundle\LocationBundle;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\ResolveDoctrineTargetEntitiesPass;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AstoundLocationBundle extends Bundle
{
public static function getSupportedDrivers()
{
return array(
SyliusResourceBundle::DRIVER_DOCTRINE_ORM
);
}
public function build(ContainerBuilder $container)
{
$interfaces = array(
'Astound\Bundle\LocationBundle\Model\LocationInterface' => 'astound.model.location.class',
);
$container->addCompilerPass(new ResolveDoctrineTargetEntitiesPass('astound_location', $interfaces));
$mappings = array(
realpath(__DIR__ . '/Resources/config/doctrine/model') => 'Astound\Bundle\LocationBundle\Model',
);
$container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings, array('doctrine.orm.entity_manager'), 'astound_location.driver.doctrine/orm'));
}
}
:
NotFoundException: "astound_location.driver".
:
astound_location:
driver: doctrine/orm
:
FileLoaderLoadException: ".../app/config/astound.yml" "...//Config/config.yml". ( , "astound_location" (...//Config/astound.yml). "Astound_location"
, ! ?! ?