Beispiel #1
0
 public function testGetEmpty()
 {
     $annotation = new Annotation();
     $annotations = new Annotations(array('tag1' => $annotation));
     $this->assertNotSame($annotation, $annotations->get('tag2'));
     $this->assertInstanceOf('TRex\\Annotation\\Annotation', $annotations->get('tag2'));
 }
Beispiel #2
0
 protected static function getClassRoutes($className, $directoryPrefix, $urlPrefix, $parseActions = TRUE)
 {
     $regex = sprintf('@^Controller_%s_V(\\d+)_(.+)$@', str_replace(DIRECTORY_SEPARATOR, '_', rtrim($directoryPrefix, DIRECTORY_SEPARATOR)));
     if (preg_match($regex, $className, $matches)) {
         $version = $matches[1];
         $urlPrefix = str_replace('{version}', $version, $urlPrefix) . '/';
         $controllerName = $matches[2];
         /** @var RestfulAPI\Route $route */
         $route = Annotations::getClassAnnotation($className, self::annotationRoute);
         if (NULL === $route) {
             $route = Annotations::annotationClass(self::annotationRoute);
         }
         $route->name = $className;
         $route->value = $urlPrefix . $route->value;
         $routeDefaults = ['directory' => $directoryPrefix . 'V' . $version, 'controller' => $controllerName];
         if ($parseActions) {
             $classReflection = new ReflectionClass($className);
             $classActions = $classReflection->getMethods(ReflectionMethod::IS_PUBLIC);
             foreach ($classActions as $method) {
                 if (!$method->isFinal() && preg_match('@^action_(([^_]+)(?:_(.+))?)$@', $method->name, $actionMatches)) {
                     /** @var RestfulAPI\Route $actionRoute */
                     $actionRoute = Annotations::getMethodAnnotation($method->name, self::annotationRoute, $className);
                     if (NULL !== $actionRoute) {
                         $actionRoute->name = $className . '::' . Arr::get($actionMatches, 1, $method->name);
                         $actionRoute->value = $urlPrefix . $actionRoute->value;
                         $actionRoute->defaults['action'] = Arr::get($actionMatches, 3);
                         self::makeRoute($actionRoute, $routeDefaults);
                     }
                 }
             }
         }
         self::makeRoute($route, $routeDefaults);
     }
 }
 /**
  * @test
  * @profile fork
  */
 public function testParse()
 {
     split_time('Reset');
     $annotations = Annotations::get('Components\\Type_Test_Unit_Case_Annotations_Entity');
     split_time('Invoke Annotations::get(Components\\Type_Test_Unit_Case_Annotations_Entity)');
     $annotations = Annotations::get('Components\\Type_Test_Unit_Case_Annotations_Entity');
     split_time('Invoke Annotations::get(Components\\Type_Test_Unit_Case_Annotations_Entity)');
     assertTrue($annotations->hasTypeAnnotation(Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(name)');
     assertTrue($annotations->hasTypeAnnotation(Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(name)');
     assertTrue($annotations->hasTypeAnnotation('package'));
     split_time('Invoke Annotations$hasMethodAnnotation(package)');
     assertFalse($annotations->hasTypeAnnotation('version'));
     split_time('Invoke Annotations$hasMethodAnnotation(version)');
     assertTrue($annotations->hasMethodAnnotation('poke', Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(poke)');
     assertTrue($annotations->hasMethodAnnotation('poke', Annotation_Name::NAME));
     split_time('Invoke Annotations$hasMethodAnnotation(poke)');
     $pokeName = $annotations->getMethodAnnotation('poke', Annotation_Name::NAME);
     split_time('Invoke Annotations$getMethodAnnotation(poke)');
     $pokeName = $annotations->getMethodAnnotation('poke', Annotation_Name::NAME);
     split_time('Invoke Annotations$getMethodAnnotation(poke)');
     $annotations = Annotations::get(__CLASS__);
     split_time('Invoke Annotations::get(' . __CLASS__ . ')');
     $annotations = Annotations::get(__CLASS__);
     split_time('Invoke Annotations::get(' . __CLASS__ . ')');
     assertEquals('poke', $pokeName->value);
 }
 public function __construct($class_, Test_Unit_Runner $runner_ = null)
 {
     $this->m_runner = $runner_;
     $this->m_class = new \ReflectionClass($class_);
     $rootPath = realpath($runner_->getTestRootPath());
     $testClassPath = realpath($this->m_class->getFileName());
     $this->m_path = str_replace("{$rootPath}/", '', $testClassPath);
     $annotations = Annotations::get($class_);
     foreach ($this->m_class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
         if ($ignoreAnnotation = $annotations->getMethodAnnotation($method->name, Annotation_Ignore::NAME)) {
             if (null !== $ignoreAnnotation->value && false === @method_exists($this->m_class->name, $ignoreAnnotation->value)) {
                 throw new Exception_IllegalArgument('test/unit/internal/dynamicproxy', sprintf('Illegal argument in @%1$s(value=%4$s) %2$s::%3$s().', Annotation_Ignore::NAME, $this->m_class->name, $method->name, $ignoreAnnotation->value));
             } else {
                 if (null !== $ignoreAnnotation->value) {
                     if (false !== ($reason = call_user_func([$this->m_class->name, $ignoreAnnotation->value]))) {
                         if (is_string($reason)) {
                             $this->m_skippedTestsReasons[$method->name] = $reason;
                         }
                         $this->m_skippedTests[$method->name] = true;
                     }
                 } else {
                     $this->m_skippedTests[$method->name] = true;
                 }
             }
         }
         if ($testAnnotation = $annotations->getMethodAnnotation($method->name, Annotation_Test::NAME)) {
             array_push($this->m_tests, $method);
             $expectedFail = $testAnnotation->expectedFail;
             $expectedException = $testAnnotation->expectedException;
             if (null !== $expectedException && false === @class_exists($expectedException)) {
                 throw new Exception_IllegalArgument('test/unit/internal/dynamicproxy', sprintf('Illegal argument in @%1$s(expectedException=%4$s) %2$s::%3$s().', Annotation_Test::NAME, $this->m_class->name, $method->name, $expectedException));
             }
             if (null !== $expectedException) {
                 $this->m_exceptionsExpected[$method->name] = $expectedException;
             }
             if (null != $expectedFail && 'false' !== trim(strtolower($expectedFail))) {
                 $this->m_failedExpected[$method->name] = true;
             }
         }
         /*
          * Search for Before-/AfterMethod/-Class/-Suite annotations
          * Only the first occurence per method will be respected.
          */
         foreach (self::$m_staticAnnotations as $staticAnnotation) {
             if ($annotations->hasMethodAnnotation($method->name, $staticAnnotation)) {
                 $this->m_mappedMethods[$staticAnnotation] = $method->name;
                 break;
             }
         }
         $this->m_methods[$method->name] = $method;
         if ($profileAnnotation = $annotations->getMethodAnnotation($method->name, Annotation_Profile::NAME)) {
             $this->m_profileMethods[$method->name] = null;
             if (Annotation_Profile::VALUE_FORK == $profileAnnotation->value) {
                 $this->m_profileMethodsForked[$method->name] = null;
             }
         }
     }
 }
 /**
  * @param string $type_
  *
  * @return array|string
  */
 public static function arrayForType($type_)
 {
     if (isset(self::$m_cache[$type_])) {
         return self::$m_cache[$type_];
     }
     if ($map = Cache::get('components/object/properties/' . md5($type_))) {
         return self::$m_cache[$type_] = $map;
     }
     $annotations = Annotations::get($type_);
     $map = [];
     foreach ($annotations->getPropertyAnnotations() as $propertyName => $propertyAnnotations) {
         if (isset($propertyAnnotations[Annotation_Transient::NAME])) {
             continue;
         }
         $property = array('name' => $propertyName, 'type' => null, 'nameMapped' => $propertyName, 'typeMapped' => null);
         foreach ($propertyAnnotations as $annotation) {
             if ($annotation instanceof Annotation_Type) {
                 if (false === strpos($annotation->value, '[')) {
                     $property['type'] = $annotation->value;
                     if (Primitive::isNative($property['type'])) {
                         $property['type'] = Primitive::asBoxed($property['type']);
                     }
                 } else {
                     if (false !== ($pos = strpos($annotation->value, '[]'))) {
                         $property['type'] = HashMap::TYPE;
                         $property['args'] = ltrim(substr($annotation->value, $pos), '\\');
                         if (Primitive::isNative($property['args'])) {
                             $property['args'] = Primitive::asBoxed($property['args']);
                         }
                     } else {
                         $annotationValue = rtrim($annotation->value, ']');
                         $property['type'] = ltrim(substr($annotationValue, 0, strpos($annotationValue, '[')), '\\');
                         $property['args'] = ltrim(substr($annotationValue, strpos($annotationValue, '[') + 1), '\\');
                         if (Primitive::isNative($property['type'])) {
                             $property['type'] = Primitive::asBoxed($property['type']);
                         }
                         if (Primitive::isNative($property['args'])) {
                             $property['args'] = Primitive::asBoxed($property['args']);
                         }
                     }
                 }
             }
             if ($annotation instanceof Annotation_Name) {
                 $property['nameMapped'] = $annotation->value;
             }
         }
         $map[$propertyName] = $property;
     }
     Cache::set('components/object/properties/' . md5($type_), $map);
     return self::$m_cache[$type_] = $map;
 }
 /**
  * Registers binding annotations.
  */
 private static function initialize()
 {
     if (self::$m_initialized) {
         return;
     }
     Annotations::registerAnnotations(array(Annotation_Inject::NAME => Annotation_Inject::TYPE, Annotation_Named::NAME => Annotation_Named::TYPE, Annotation_Binding_Provider::NAME => Annotation_Binding_Provider::TYPE));
     self::$m_initialized = true;
 }
Beispiel #7
0
<?php

require __DIR__ . '/classes/ClassLoader.class.php';
ClassLoader::init('.', __DIR__ . '/classes');
//$t = new TestClass();
$ann = Annotations::getClassAnnotations('TestClass');
$ann->setFlags(ArrayObject::ARRAY_AS_PROPS);
print_r($ann->MegaAnnotation);
$pann = Annotations::getPropertyAnnotations('User', 'name');
Beispiel #8
0
 public function getMyAnnotationsByCeHim($ceHim = 0, $state = null, $imageId = 0)
 {
     $annotationTable = new Annotations();
     $dbAdapter = $annotationTable->getAdapter();
     $select = $dbAdapter->select();
     $select->from(array('annos' => Annotations::TABLE_NAME));
     $fetch = true;
     if ($state == null) {
         $select->where(Annotations::COL_CE_HAS_IMAGE_ID . "=?", $ceHim, 'int') . $select->where(Annotations::COL_PART_ID . "=?", $this->getParticipantId(), 'int');
         $select->where(Annotations::COL_GROUP . "!=?", 1, 'int');
         $select->where(Annotations::COL_WS_REF . "!=?", 1, 'int');
         $select->where(Annotations::COL_WEBGR_REF . "!=?", 1, 'int');
     } else {
         if ($state == 'groupState') {
             $select->where(Annotations::COL_CE_HAS_IMAGE_ID . "=?", $ceHim, 'int');
             $select->where(Annotations::COL_GROUP . "=?", 1, 'int');
         } else {
             if ($state == 'ws-refState') {
                 // check for user roles
                 $storage = Zend_Auth::getInstance()->getStorage()->read();
                 $roleConst = User::COL_ROLE;
                 if ($storage->{$roleConst} == 'admin' || $storage->{$roleConst} == 'manager' || $this->getParticipantRole() == 'Coordinator') {
                     $ceTable = new CalibrationExercise();
                     $ceArray = $ceTable->find($this->getCurrentCeID())->toArray();
                     $select->join(array('ceHim' => CeHasImage::TABLE_NAME), 'annos.' . Annotations::COL_CE_HAS_IMAGE_ID . "=" . 'ceHim.' . CeHasImage::COL_ID);
                     $select->join(array('caex' => CalibrationExercise::TABLE_NAME), 'ceHim.' . CeHasImage::COL_CALIBRATION_EXERCISE_ID . "=" . 'caex.' . CalibrationExercise::COL_ID);
                     $select->join(array('im' => Image::TABLE_NAME), 'ceHim.' . CeHasImage::COL_IMAGE_ID . "=" . 'im.' . Image::COL_ID);
                     $select->where(CalibrationExercise::COL_EXPERTISE_ID . "=?", $this->namespace->ceArray[0][CalibrationExercise::COL_EXPERTISE_ID]);
                     $select->where(CalibrationExercise::COL_KEY_TABLE_ID . "=?", $this->namespace->ceArray[0][CalibrationExercise::COL_KEY_TABLE_ID]);
                     $select->where('im.' . Image::COL_ID . "=?", $imageId, 'int');
                     $select->where('caex.' . CalibrationExercise::COL_WORKSHOP_ID . "=?", $ceArray[0][CalibrationExercise::COL_WORKSHOP_ID], 'int');
                     $select->where(Annotations::COL_WS_REF . "=?", 1, 'int');
                 } else {
                     $fetch = false;
                 }
             } else {
                 if ($state == 'webgr-refState') {
                     // check for user roles
                     $storage = Zend_Auth::getInstance()->getStorage()->read();
                     $roleConst = User::COL_ROLE;
                     if ($storage->{$roleConst} == 'admin' || $storage->{$roleConst} == 'manager' || $this->getParticipantRole() == 'Coordinator') {
                         $select->join(array('ceHim' => CeHasImage::TABLE_NAME), 'annos.' . Annotations::COL_CE_HAS_IMAGE_ID . "=" . 'ceHim.' . CeHasImage::COL_ID);
                         $select->join(array('caex' => CalibrationExercise::TABLE_NAME), 'ceHim.' . CeHasImage::COL_CALIBRATION_EXERCISE_ID . "=" . 'caex.' . CalibrationExercise::COL_ID);
                         $select->join(array('im' => Image::TABLE_NAME), 'ceHim.' . CeHasImage::COL_IMAGE_ID . "=" . 'im.' . Image::COL_ID);
                         $select->where(CalibrationExercise::COL_EXPERTISE_ID . "=?", $this->namespace->ceArray[0][CalibrationExercise::COL_EXPERTISE_ID]);
                         $select->where(CalibrationExercise::COL_KEY_TABLE_ID . "=?", $this->namespace->ceArray[0][CalibrationExercise::COL_KEY_TABLE_ID]);
                         $select->where('im.' . Image::COL_ID . "=?", $imageId, 'int');
                         $select->where(Annotations::COL_WEBGR_REF . "=?", 1, 'int');
                     } else {
                         $fetch = false;
                     }
                 }
             }
         }
     }
     //return $select->__toString();
     if ($fetch) {
         return $dbAdapter->fetchAll($select);
     } else {
         return array();
     }
 }
<?php

namespace Components;

Annotations::registerAnnotations([Annotation_Cache::NAME => Annotation_Cache::TYPE, Annotation_Collection::NAME => Annotation_Collection::TYPE, Annotation_Id::NAME => Annotation_Id::TYPE, Annotation_Transient::NAME => Annotation_Transient::TYPE]);
Resource_Type::registerResourceType('mysql', Persistence_Resource_Pdo_Mysql::type());
Resource_Type::registerResourceType('mongodb', Persistence_Resource_Mongodb::type());
Persistence_Resource_Schema::serve('schema');
Persistence::registerResource('nosql', ['mongodb://127.0.0.1/' . COMPONENTS_INSTANCE_CODE]);
Debug::addFlagListener(function ($active_, array $flags_) {
    if ($active_) {
        $bits = [];
        if (isset($flags_[Persistence::LOG_STATEMENTS])) {
            $bits[] = Persistence::BIT_LOG_STATEMENTS;
        }
        if (isset($flags_[Persistence::LOG_QUERIES])) {
            $bits[] = Persistence::BIT_LOG_QUERIES;
        }
        if (isset($flags_[Persistence::PROFILE])) {
            $bits[] = Persistence::BIT_PROFILE;
        }
        Persistence::$debugMode = Bitmask::getBitmaskForBits($bits);
    } else {
        Persistence::$debugMode = Persistence::BIT_NO_DEBUG;
    }
});
 /**
  * @param string $name
  * @param string $param
  * @param string $methodName
  * @param mixed  $default
  *
  * @return mixed
  */
 public function getAnnotationParam($name, $param, $methodName = NULL, $default = NULL)
 {
     return Annotations::getAnnotationParam($name, $param, $this, $methodName, $default);
 }
Beispiel #11
0
 /**
  * Returns array of classes persistent parameters. They have public visibility and are non-static.
  * This default implementation detects persistent parameters by annotation @persistent.
  * @return array
  */
 public static function getPersistentParams()
 {
     $rc = new ReflectionClass(func_get_arg(0));
     $params = array();
     foreach ($rc->getProperties() as $rp) {
         if ($rp->isPublic() && !$rp->isStatic() && Annotations::get($rp, 'persistent')) {
             $params[] = $rp->getName();
         }
     }
     return $params;
 }
Beispiel #12
0
 /**
  * Get all annotations for the method name on the given class.
  *
  * @param string $class  Fully qualified class name
  * @param string $method Method name
  *
  * @return ConfigObject ConfigObject instance containing all annotations.
  */
 protected function annotationsFromMethod($class, $method)
 {
     return Annotations::getMethodAnnotations($class, $method);
 }
 protected function initialize()
 {
     $a = Annotations::get($this->entityType);
     $this->entityName = Runtime_Classloader::lookupName($this->entityType);
     if ($annotation = $a->getTypeAnnotation(Annotation_Name::NAME)) {
         $this->collectionName = $a->getTypeAnnotation(Annotation_Name::NAME)->value;
     } else {
         $this->collectionName = strtolower(substr($this->entityType, strrpos($this->entityType, '_') + 1));
     }
     if ($annotation = $a->getTypeAnnotation(Annotation_Collection::NAME)) {
         $this->collectionType = Runtime_Classloader::lookup($annotation->value);
     } else {
         $this->collectionType = Entity_Collection::TYPE;
     }
     $this->autoIncrement = true;
     foreach ($a->getPropertyAnnotations() as $property => $annotations) {
         if (isset($annotations[Annotation_Id::NAME])) {
             $this->collectionPrimaryKey = $property;
             $this->collectionPrimaryKeyAutoIncrement = Boolean::valueIsTrue($annotations[Annotation_Id::NAME]->auto);
         }
     }
 }
 public static function getDirContents($dir, &$results = array())
 {
     $files = scandir($dir);
     foreach ($files as $key => $value) {
         $path = realpath($dir . DIRECTORY_SEPARATOR . $value);
         if (!is_dir($path)) {
             $results[] = $path;
         } else {
             if (is_dir($path) && $value != "." && $value != "..") {
                 Annotations::getDirContents($path, $results);
                 $results[] = $path;
             }
         }
     }
     return $results;
 }
Beispiel #15
0
 /**
  * Method annotations test.
  * @return void
  */
 public function testMethodAnnotations()
 {
     $rm = new ReflectionMethod('TestClass', 'bar');
     $tmp = Annotations::getAll($rm);
     $this->assertEquals('admin', $tmp["RolesAllowed"][0][0]);
     $this->assertEquals('web editor', $tmp["RolesAllowed"][0][1]);
 }
Beispiel #16
0
 private static function execute_admin()
 {
     global $RTR, $CI, $EXT, $BM, $URI, $OUT;
     // process annotations so that tokens are defined
     WPCI::process_menu_annotations();
     if ($token = isset($_REQUEST['page']) ? $_REQUEST['page'] : null) {
         $class = null;
         $method = null;
         $app = null;
         $directory = null;
         $app_path = null;
         // exact match for token?
         if (isset(WPCI::$app_index[$token])) {
             // load the menu settings
             $menu = WPCI::$app_index[$token];
             // tell WPCI which app is active
             $app = $menu['app'];
             WPCI::activate($app);
             // load the application controller
             $app_path = $menu['app_path'];
             require_once $app_path;
             $BM->mark('loading_time_base_classes_end');
             // create an instance of the controller
             $class = $menu['class'];
             $method = $menu['method_name'];
         } else {
             if ($token == 'wp-ci') {
                 $app = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
                 $class = isset($_REQUEST['c']) ? strtolower($_REQUEST['c']) : 'settings';
                 $method = isset($_REQUEST['m']) ? $_REQUEST['m'] : 'index';
                 $directory = isset($_REQUEST['d']) ? $_REQUEST['d'] : null;
                 // if app is specified, activate it... (otherwise the core application will be used)
                 if ($app) {
                     WPCI::activate($app);
                 }
                 if ($directory) {
                     $app_path = WPCI::active_app_path() . "/controllers/{$directory}/{$class}" . EXT;
                 } else {
                     $app_path = WPCI::active_app_path() . "/controllers/{$class}" . EXT;
                 }
                 if (!file_exists($app_path)) {
                     wp_die("I don't know how to do <b>{$class}/{$method}</b>.");
                 }
                 // load the contorller
                 require_once $app_path;
             }
         }
         if ($class && $method) {
             // fake the router into thinking he did his job...
             $RTR->set_app($app);
             $RTR->set_class($class);
             $RTR->set_method($method);
             $RTR->set_directory($directory);
             $BM->mark('loading_time_base_classes_end');
             if (!class_exists($class)) {
                 wp_die("I can't find <b>{$class}/{$method}</b>.");
             }
             // make sure app class is at the top of the annotations stack
             $ann = Annotations::get("{$app}/{$class}", $app_path);
             // evaluate permissions, but only when they are specified for evaluation
             $user_can = true;
             if (count($ann->for_class('user_must') + $ann->for_class('user_can') + $ann->for_method($method, 'user_must') + $ann->for_method($method, 'user_can'))) {
                 // first, test all user_must annotations
                 foreach ($ann->for_class('user_must') as $cap) {
                     if (!current_user_can($cap)) {
                         $user_can = false;
                         break;
                     }
                 }
                 // next, test for method
                 if ($user_can) {
                     foreach ($ann->for_method($method, 'user_must') as $cap) {
                         if (!current_user_can($cap)) {
                             $user_can = false;
                             break;
                         }
                     }
                     // then, test user_can
                     if ($user_can) {
                         $user_can = false;
                         foreach ($ann->for_class('user_can') as $cap) {
                             $user_can = $user_can || current_user_can($cap);
                         }
                         foreach ($ann->for_method($method, 'user_can') as $cap) {
                             $user_can = $user_can || current_user_can($cap);
                         }
                     }
                 }
             }
             if ($method == 'controller' or strncmp($method, '_', 1) == 0 or in_array(strtolower($method), array_map('strtolower', get_class_methods('Controller'))) or !$user_can) {
                 wp_die("You're not allowed to do <b>{$class}/{$method}</b>.");
             }
             $EXT->_call_hook('pre_controller');
             $BM->mark('controller_execution_time_( ' . $class . ' / ' . $method . ' )_start');
             $CI = new $class();
             $CI->method = strtoupper($_SERVER['REQUEST_METHOD']);
             $EXT->_call_hook('post_controller_constructor');
             // ajax annotation = no header
             $is_ajax = $ann->for_class('ajax') || $ann->for_method($method, 'ajax');
             $no_chrome = $ann->for_class('no_chrome') || $ann->for_method($method, 'chrome');
             if ($is_ajax || $no_chrome) {
                 $_GET['noheader'] = 1;
             }
             $ajax_content = null;
             // Is there a "remap" function?
             if (method_exists($CI, '_remap')) {
                 $CI->_remap($method);
             } else {
                 // is_callable() returns TRUE on some versions of PHP 5 for private and protected
                 // methods, so we'll use this workaround for consistent behavior
                 if (!in_array(strtolower($method), array_map('strtolower', get_class_methods($CI)))) {
                     wp_die("I'm not allowed to do <b>{$class}/{$method}</b>.");
                 }
                 log_message('debug', "Executing {$class}/{$method}()");
                 // Call the requested method.
                 // Any URI segments present (besides the class/function) will be passed to the method for convenience
                 if ($is_ajax || $no_chrome) {
                     ob_start();
                 }
                 call_user_func_array(array(&$CI, $method), array());
                 if ($is_ajax || $no_chrome) {
                     $ajax_content = ob_get_clean();
                 }
             }
             $BM->mark('controller_execution_time_( ' . $class . ' / ' . $method . ' )_end');
             $EXT->_call_hook('post_controller');
             $EXT->_call_hook('post_system');
             if (class_exists('CI_DB') and isset($CI->db)) {
                 $CI->db->close();
             }
             // if this was an ajax request, then we display the output and terminate
             if ($is_ajax || $no_chrome) {
                 if ($is_ajax) {
                     header('Content-type: application/json', true);
                 }
                 echo $ajax_content;
                 $OUT->_display();
                 exit(0);
             }
         }
     }
 }
<?php

namespace RCSBase\Doctrine2\Annotation;

Annotations::$reader = new \Doctrine\Common\Annotations\AnnotationReader();
class Annotations
{
    public static $reader;
    public static function getAnnotationsForClass($className)
    {
        return Annotations::$reader->getClassAnnotations(new \ReflectionClass($className));
    }
}
 private static function initialize()
 {
     Annotations::registerAnnotations([Annotation_Application::NAME => Annotation_Application::TYPE, Annotation_Method_Delete::NAME => Annotation_Method_Delete::TYPE, Annotation_Method_Get::NAME => Annotation_Method_Get::TYPE, Annotation_Method_Options::NAME => Annotation_Method_Options::TYPE, Annotation_Method_Post::NAME => Annotation_Method_Post::TYPE, Annotation_Method_Put::NAME => Annotation_Method_Put::TYPE, Annotation_Param_Path::NAME => Annotation_Param_Path::TYPE, Annotation_Param_Query::NAME => Annotation_Param_Query::TYPE]);
     self::$m_initialized = true;
 }
 /**
  * store annotations in the cache
  *
  * @param  \stubbles\reflect\annotation\Annotations  $annotations
  */
 public static function put(Annotations $annotations)
 {
     self::$annotations[$annotations->target()] = serialize($annotations);
     self::$unserialized[$annotations->target()] = $annotations;
     self::$cacheChanged = true;
 }
Beispiel #20
0
 /**
  * Returns array of persistent components.
  * This default implementation detects components by class-level annotation @persistent(cmp1, cmp2).
  * @return array
  */
 public static function getPersistentComponents()
 {
     return (array) Annotations::get(new ReflectionClass(func_get_arg(0)), 'persistent');
 }
 protected static function registerAnnotations()
 {
     if (false === self::$m_annotationsRegistered) {
         Annotations::registerAnnotations(array(Annotation_AfterClass::NAME => Annotation_AfterClass::TYPE, Annotation_AfterMethod::NAME => Annotation_AfterMethod::TYPE, Annotation_AfterSuite::NAME => Annotation_AfterSuite::TYPE, Annotation_BeforeClass::NAME => Annotation_BeforeClass::TYPE, Annotation_BeforeMethod::NAME => Annotation_BeforeMethod::TYPE, Annotation_BeforeSuite::NAME => Annotation_BeforeSuite::TYPE, Annotation_Ignore::NAME => Annotation_Ignore::TYPE, Annotation_Profile::NAME => Annotation_Profile::TYPE, Annotation_Test::NAME => Annotation_Test::TYPE));
         self::$m_annotationsRegistered = true;
     }
 }