예제 #1
0
 protected function parseService(SimpleXMLElement $serviceXml, Config $config)
 {
     $service = new Service($serviceXml->getAttributeAsPhp("id"), $serviceXml->getAttributeAsPhp("class"), $serviceXml->getAttributeAsPhp("scope"));
     static::registerNamespace($serviceXml);
     foreach ($serviceXml->xpath(".//config:tag") as $tagXml) {
         $parameters = array();
         foreach ($tagXml->attributes() as $k => $v) {
             $parameters[$k] = $v;
         }
         $service->addTag(new Tag($parameters["name"], $parameters));
     }
     $config->addService($service);
 }
 /**
  * @param \TheliaStudio\Parser\Entity\Table[] $tables
  */
 protected function generateConfiguration(array $tables, $moduleCode)
 {
     $config = new Config();
     foreach ($tables as $table) {
         // Add loop
         $config->addLoop(new Loop($table->getLoopType(), $moduleCode . "\\Loop\\" . $table->getTableName()));
         // Add forms
         $config->addForm(new Form($table->getRawTableName() . ".create", $moduleCode . "\\Form\\" . $table->getTableName() . "CreateForm"));
         $config->addForm(new Form($table->getRawTableName() . ".update", $moduleCode . "\\Form\\" . $table->getTableName() . "UpdateForm"));
         // Add action
         $service = new Service("action." . strtolower($moduleCode) . "." . $table->getRawTableName() . "_table", $moduleCode . "\\Action\\" . $table->getTableName() . "Action");
         $service->addTag(new Tag("kernel.event_subscriber"));
         $config->addService($service);
         // Add form type
         $formType = new Service(strtolower($moduleCode) . ".form.type." . $table->getRawTableName() . "_id", $moduleCode . "\\Form\\Type\\" . $table->getTableName() . "IdType");
         $formType->addArgument(new Argument(null, Argument::TYPE_SERVICE, "thelia.translator"));
         $formType->addTag(new Tag("thelia.form.type"));
         $config->addService($formType);
     }
     return $config;
 }