コード例 #1
0
 /**
  * Scan the files in the configured path for controllers
  *
  * To dynamically scan controllers from the source files
  * use PHP Reflection to find the controllers.
  *
  * The returning result is an array of Admin_Model_DbRow_Controller elements
  *
  * @return array
  */
 public function getControllers()
 {
     $resources = array();
     $directory = new DirectoryIterator($this->path);
     $CcFilter = new Zend_Filter_Word_CamelCaseToDash();
     while ($directory->valid()) {
         if ($directory->isFile() && !in_array($directory->getFilename(), $this->skip, TRUE)) {
             // load the file
             require_once $directory->getPathname();
             $reflect = new Zend_Reflection_File($directory->getPathName());
             $name = substr($reflect->getClass()->getName(), strrpos($reflect->getClass()->getName(), "_") + 1);
             $controller = new Admin_Model_DbRow_Controller(array('moduleName' => 'webdesktop', 'controllerName' => strtolower($name), 'virtual' => 1));
             $resources[] = $controller;
         }
         $directory->next();
     }
     return $resources;
 }
コード例 #2
0
ファイル: Reader.php プロジェクト: BGCX262/zsoc-svn-to-git
 public function handleMethod($object, $method, $args = null)
 {
     $reflection = new Zend_Reflection_File($this->_file);
     $reflectionClass = $reflection->getClass(get_class($object));
     $reflectionMethod = $reflectionClass->getMethod($method);
     $docblock = $reflectionMethod->getDocblock();
     $tags = $docblock->getTags();
     foreach ($tags as $tag) {
         //$tag = new Zend_Reflection_Docblock_Tag();
         $name = ucfirst($tag->getName());
         $className = $name . 'Annotation';
         var_dump($className);
         try {
             $className = $this->getLoader()->load($className);
             $annotation = new $className();
             $annotation->handle($tag->getDescription(), $object, $args);
         } catch (Zend_Loader_PluginLoader_Exception $e) {
             throw $e;
         }
     }
 }
コード例 #3
0
 public function testFileCanReflectFileWithInterface()
 {
     $fileToRequire = dirname(__FILE__) . '/_files/TestSampleInterface.php';
     require_once $fileToRequire;
     $reflectionFile = new Zend_Reflection_File($fileToRequire);
     $class = $reflectionFile->getClass();
     $this->assertEquals('Zend_Reflection_TestSampleInterface', $class->getName());
     $this->assertTrue($class->isInterface());
 }
コード例 #4
0
ファイル: MVC.php プロジェクト: BGCX262/zupal-svn-to-git
 /**
  *
  * @param string $pParam
  * @return string
  */
 public function get_controller_class_object()
 {
     if (file_exists($this->controller_path())) {
         $zrf = new Zend_Reflection_File($this->controller_path());
         $crf = array_shift($zrf->getClass($this->controller_class_name()));
         $class = new Zend_CodeGenerator_Php_Class($crf);
     } else {
         $params = array('name' => $this->controller_class_name(), 'extendsClass' => 'Zupal_Controller_Abstract');
         if ($this->get_action()) {
             $mp = array('name' => $this->get_action() . 'Action');
             $action = new Zend_CodeGenerator_Php_Method($mp);
         }
         $class = new Zend_CodeGenerator_Php_Class($params);
     }
     return $class;
 }