本文整理汇总了PHP中Zend_CodeGenerator_Php_Class::setImplementedInterfaces方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_CodeGenerator_Php_Class::setImplementedInterfaces方法的具体用法?PHP Zend_CodeGenerator_Php_Class::setImplementedInterfaces怎么用?PHP Zend_CodeGenerator_Php_Class::setImplementedInterfaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_CodeGenerator_Php_Class
的用法示例。
在下文中一共展示了Zend_CodeGenerator_Php_Class::setImplementedInterfaces方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateAction
/**
* Generate the action
*
* This is a gigantic method used to generate the actual Action code. It
* uses the properties, description, name, and routes passed to it.
*
* This method uses the Zend_CodeGenerator_Php_* family to identify and create the
* new files.
*
* @param string $name The name of the action
* @param array $properties An array of properties related to an action
* @param string $description A description for an action. Default false.
* @param string $route The custom route for that action. Default false.
*
* @return string A generated file.
*/
private function generateAction($name, $properties, $description = false, $route = false)
{
$docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'Required parameters', 'tags' => array(new Zend_CodeGenerator_Php_Docblock_Tag(array('name' => 'var', 'datatype' => 'array', 'description' => 'An array of required parameters.')))));
$class = new Zend_CodeGenerator_Php_Class();
$class->setName('Action_' . $name);
$class->setExtendedClass('Frapi_Action');
$class->setImplementedInterfaces(array('Frapi_Action_Interface'));
$tags = array(array('name' => 'link', 'description' => 'http://getfrapi.com'), array('name' => 'author', 'description' => 'Frapi <frapi@getfrapi.com>'));
if ($route !== false) {
$tags[] = array('name' => 'link', 'description' => $route);
}
$classDocblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'Action ' . $name . ' ', 'longDescription' => $description !== false ? $description : 'A class generated by Frapi', 'tags' => $tags));
$class->setDocblock($classDocblock);
$class->setProperties(array(array('name' => 'requiredParams', 'visibility' => 'protected', 'defaultValue' => $properties, 'docblock' => $docblock), array('name' => 'data', 'visibility' => 'private', 'defaultValue' => array(), 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'The data container to use in toArray()', 'tags' => array(new Zend_CodeGenerator_Php_Docblock_Tag(array('name' => 'var', 'datatype' => 'array', 'description' => 'A container of data to fill and return in toArray()'))))))));
$methods = array();
$docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'To Array', 'longDescription' => "This method returns the value found in the database \n" . 'into an associative array.', 'tags' => array(new Zend_CodeGenerator_Php_Docblock_Tag_Return(array('datatype' => 'array')))));
$toArrayBody = ' ' . "\n";
if (!empty($properties)) {
foreach ($properties as $p) {
$toArrayBody .= '$this->data[\'' . $p . '\'] = ' . '$this->getParam(\'' . $p . '\', self::TYPE_OUTPUT);' . "\n";
}
}
$toArrayBody .= 'return $this->data;';
$methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'toArray', 'body' => $toArrayBody, 'docblock' => $docblock));
$executeActionBody = '';
if (!empty($properties)) {
$executeActionBody = ' $valid = $this->hasRequiredParameters($this->requiredParams);
if ($valid instanceof Frapi_Error) {
return $valid;
}';
}
$executeActionBody .= "\n\n" . 'return $this->toArray();';
$docblockArray = array('shortDescription' => '', 'longDescription' => '', 'tags' => array(new Zend_CodeGenerator_Php_Docblock_Tag_Return(array('datatype' => 'array'))));
$docblock = new Zend_CodeGenerator_Php_Docblock(array());
$docblockArray['shortDescription'] = 'Default Call Method';
$docblockArray['longDescription'] = 'This method is called when no specific ' . 'request handler has been found';
$methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executeAction', 'body' => $executeActionBody, 'docblock' => $docblockArray));
$docblockArray['shortDescription'] = 'Get Request Handler';
$docblockArray['longDescription'] = 'This method is called when a request is a GET';
$methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executeGet', 'body' => $executeActionBody, 'docblock' => $docblockArray));
$docblockArray['shortDescription'] = 'Post Request Handler';
$docblockArray['longDescription'] = 'This method is called when a request is a POST';
$methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executePost', 'body' => $executeActionBody, 'docblock' => $docblockArray));
$docblockArray['shortDescription'] = 'Put Request Handler';
$docblockArray['longDescription'] = 'This method is called when a request is a PUT';
$methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executePut', 'body' => $executeActionBody, 'docblock' => $docblockArray));
$docblockArray['shortDescription'] = 'Delete Request Handler';
$docblockArray['longDescription'] = 'This method is called when a request is a DELETE';
$methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executeDelete', 'body' => $executeActionBody, 'docblock' => $docblockArray));
$docblockArray['shortDescription'] = 'Head Request Handler';
$docblockArray['longDescription'] = 'This method is called when a request is a HEAD';
$methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executeHead', 'body' => $executeActionBody, 'docblock' => $docblockArray));
$class->setMethods($methods);
$file = new Zend_CodeGenerator_Php_File();
$file->setClass($class);
return $file->generate();
}
示例2: testImplementedInterfacesAccessors
public function testImplementedInterfacesAccessors()
{
$codeGenClass = new Zend_CodeGenerator_Php_Class();
$codeGenClass->setImplementedInterfaces(array('Class1', 'Class2'));
$this->assertEquals($codeGenClass->getImplementedInterfaces(), array('Class1', 'Class2'));
}