Ejemplo n.º 1
0
 /**
  * How is accessed object property? by getter, isser or public property
  * Code from Symfony Form Component used - class PropertyPath
  *
  * @param Object $object
  * @param string $name
  * @return mixed array(methodName) or propertyName
  */
 private function getPropertyAccessMethod($object, $name)
 {
     $class = get_class($object);
     if (!isset($this->reflections[$class])) {
         $this->reflections[$class] = new \ReflectionClass($object);
     }
     $reflClass = $this->reflections[$class];
     $camelProp = $this->camelizer->camelize($name);
     $property = $camelProp;
     $getter = 'get' . $camelProp;
     $isser = 'is' . $camelProp;
     if ($reflClass->hasMethod($getter)) {
         if (!$reflClass->getMethod($getter)->isPublic()) {
             throw new ExtJSException(sprintf('Method "%s()" is not public in class "%s"', $getter, $reflClass->getName()));
         }
         return array($getter);
     } else {
         if ($reflClass->hasMethod($isser)) {
             if (!$reflClass->getMethod($isser)->isPublic()) {
                 throw new ExtJSException(sprintf('Method "%s()" is not public in class "%s"', $isser, $reflClass->getName()));
             }
             return array($isser);
         } else {
             if ($reflClass->hasMethod('__get')) {
                 // needed to support magic method __get
                 return $object->{$property};
             } else {
                 if ($reflClass->hasProperty($property)) {
                     if (!$reflClass->getProperty($property)->isPublic()) {
                         throw new ExtJSException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()" or "%s()"?', $property, $reflClass->getName(), $getter, $isser));
                     }
                     return $property;
                 } else {
                     if (property_exists($object, $property)) {
                         // needed to support \stdClass instances
                         return $property;
                     }
                 }
             }
         }
     }
     throw new ExtJSException(sprintf('Neither property "%s" nor method "%s()" nor method "%s()" exists in class "%s"', $property, $getter, $isser, $reflClass->getName()));
 }
Ejemplo n.º 2
0
 protected function getDataKind()
 {
     return Camelizer::camelize(explode(' ', strtolower(trim($this->getRootClass()->getLabel()))), false);
 }