Example #1
0
 /**
  * @return mixed
  */
 protected function getKeyKey()
 {
     $n = get_called_class();
     if (!isset(self::$k_cache[$n])) {
         $key = null;
         $r = $this->getReflection();
         //Parse the annotations in a class
         $reader = new \Phalcon\Annotations\Reader();
         $parsing = $reader->parse($r->getName());
         //Create the reflection
         $annotations = new \Phalcon\Annotations\Reflection($parsing);
         if ($annotations->getClassAnnotations()->has('key')) {
             $key = $annotations->getClassAnnotations()->get('key');
         } else {
             foreach ($r->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
                 if (!$property->isPublic() || $property->isStatic()) {
                     continue;
                 }
                 $f = new Field($r, $property);
                 if ($f->isKey()) {
                     $key = $property->getName();
                     break;
                 }
             }
         }
         self::$k_cache[$n] = $key;
     }
     return self::$k_cache[$n];
 }