Esempio n. 1
0
 /**
  * Returns a fully qualified class name for a given identifier.
  *
  * @param KObjectIdentifier $identifier An identifier object
  * @param bool  $fallback   Use the fallbacks to locate the identifier
  * @return string|false  Return the class name on success, returns FALSE on failure
  */
 public function locate(KObjectIdentifier $identifier, $fallback = true)
 {
     $class = KStringInflector::camelize(implode('_', $identifier->path)) . ucfirst($identifier->name);
     if (empty($identifier->domain)) {
         $domain = ucfirst($this->getObject('object.bootstrapper')->getComponentDomain($identifier->package));
     } else {
         $domain = ucfirst($identifier->domain);
     }
     $package = ucfirst($identifier->package);
     $file = ucfirst($identifier->name);
     $path = $identifier->path;
     //Make an exception for 'view' and 'module' types
     $type = !empty($path) ? array_shift($path) : '';
     if (!in_array($type, array('view', 'module'))) {
         $path = ucfirst($type) . KStringInflector::camelize(implode('_', $path));
     } else {
         $path = ucfirst($type);
     }
     //Allow locating default classes if $path is empty.
     if (empty($path)) {
         $path = $file;
         $file = '';
     }
     $info = array('identifier' => $identifier, 'class' => $class, 'package' => $package, 'domain' => $domain, 'path' => $path, 'file' => $file);
     return $this->find($info, $fallback);
 }
Esempio n. 2
0
 /**
  * Returns a fully qualified class name for a given identifier.
  *
  * @param KObjectIdentifier $identifier An identifier object
  * @param bool  $fallback   Use the fallback sequence to locate the identifier
  * @return string|false  Return the class name on success, returns FALSE on failure
  */
 public function locate(KObjectIdentifier $identifier, $fallback = true)
 {
     $domain = empty($identifier->domain) ? 'koowa' : ucfirst($identifier->domain);
     $package = ucfirst($identifier->package);
     $path = KStringInflector::camelize(implode('_', $identifier->path));
     $file = ucfirst($identifier->name);
     $class = $path . $file;
     $info = array('identifier' => $identifier, 'class' => $class, 'package' => $package, 'domain' => $domain, 'path' => $path, 'file' => $file);
     return $this->find($info, $fallback);
 }
Esempio n. 3
0
 /**
  * Set a property
  *
  * If the value is the same as the current value and the entity is loaded from the data store the value will not be
  * set. If the entity is new the value will be (re)set and marked as modified.
  *
  * Method provides support for computed properties by calling an setProperty[CamelizedName] if it exists. The setter
  * should return the computed value to set.
  *
  * @param   string  $name       The property name.
  * @param   mixed   $value      The property value.
  * @param   boolean $modified   If TRUE, update the modified information for the property
  *
  * @return  $this
  */
 public function setProperty($name, $value, $modified = true)
 {
     if (!array_key_exists($name, $this->_data) || $this->_data[$name] != $value) {
         $computed = $this->getComputedProperties();
         if (!in_array($name, $computed)) {
             //Force computed properties to re-calculate
             foreach ($computed as $property) {
                 parent::offsetUnset($property);
             }
             //Call the setter if it exists
             $setter = 'setProperty' . KStringInflector::camelize($name);
             $methods = $this->getMethods();
             if (isset($methods[$setter])) {
                 $value = $this->{$setter}($value);
             }
             //Set the property value
             parent::offsetSet($name, $value);
             //Mark the property as modified
             if ($modified || $this->isNew()) {
                 $this->_modified[$name] = $name;
             }
         }
     }
     return $this;
 }
 /**
  * @dataProvider provideNames
  */
 public function testUnderscoredToCamelize($classified, $separator, $split, $exploded, $camelized, $underscored)
 {
     $this->assertEquals(KStringInflector::camelize($underscored), $camelized);
 }