コード例 #1
0
ファイル: Generator.php プロジェクト: kujaff/versionsbundle
 /**
  * Return a ClassGenerator
  *
  * @param BaseBundle $bundleInfos
  * @param string $class Class name
  * @param string $interface Interface to use, just class name
  * @return ClassGenerator
  */
 protected function initGenerator(BaseBundle $bundleInfos, $class, $interface)
 {
     $return = new ClassGenerator();
     $return->setClassName($class);
     $return->setNamespace($bundleInfos->getNamespace() . '\\Service\\Install');
     $return->setTraits(array('kujaff\\VersionsBundle\\Model\\BundleNameFromClassName', 'kujaff\\VersionsBundle\\Model\\DoctrineHelper'));
     $return->setExtends('Symfony\\Component\\DependencyInjection\\ContainerAware');
     $return->addUse('kujaff\\VersionsBundle\\Model\\' . $interface, 'Base' . $interface);
     $return->addInterface('Base' . $interface);
     $return->setConcatTraits(true);
     return $return;
 }
コード例 #2
0
 /**
  * Generate a small \Service class
  */
 protected function generateSmallServicesShortcuts()
 {
     $generator = new ClassGenerator('Service');
     $generator->setExtractUses(false);
     $method = new Method('__callStatic');
     $method->setIsStatic(true);
     $method->addParameter(new MethodParameter('name'));
     $method->addParameter(new MethodParameter('arguments'));
     $method->addLine('return _service(str_replace(\'__\', \'.\', $name));');
     $generator->addMethod($method);
     $generator->write($this->getFileName());
 }