public function testDocBlockGetterAndSetter() { $docblockGenerator = new \Zend\Code\Generator\DocBlockGenerator(); $method = new MethodGenerator(); $method->setDocBlock($docblockGenerator); $this->assertTrue($docblockGenerator === $method->getDocBlock()); }
protected function buildDelete(ClassGenerator $generator, State $state) { $body = '$this->getEntityManager()->remove($model);'; $method = new MethodGenerator('delete'); $method->setParameter(new ParameterGenerator('model', $state->getEntityModel()->getClassName())); $method->setDocBlock(new DocBlockGenerator()); $method->getDocBlock()->setTag(new Tag\GenericTag('param', $state->getEntityModel()->getClassName() . ' $model')); $method->setBody($body); $generator->addMethodFromGenerator($method); }
public function buildGetInputFilter(ClassGenerator $generator, State $state) { $method = new MethodGenerator('getInputFilter'); $method->setDocBlock(new DocBlockGenerator()); $method->getDocBlock()->setTag(['name' => 'return', 'description' => 'InputFilterInterface']); $method->setBody(<<<EOF return (new Factory())->createInputFilter( array( ) ); EOF ); $generator->addMethodFromGenerator($method); }
/** * @param string $name * @param string $type * @return \Zend\Code\Generator\MethodGenerator */ protected function getSetter($name, $type) { $method = new MethodGenerator('set' . ucfirst($name)); $method->setParameter(new ParameterGenerator($name, $type)); $method->setDocBlock(new DocBlockGenerator()); $method->getDocBlock()->setTag(new Tag\GenericTag('param', $type . ' $' . $name)); $method->setBody('$this->' . $name . ' = $' . $name . ';'); return $method; }