コード例 #1
0
ファイル: Path.php プロジェクト: robtro/php-bandwidth
 /**
  * path should be build once
  * the object has been
  * initialized with data
  * to build a path we use
  * each dependancy, if has id in data
  * add after path and also set in 
  * object. 
  *
  * result:
  * depend1/depend1id/path
  *
  * @param object: Catapult Model Object
  * @param data: EnsureResource input or Array
  */
 public static function Make(&$object, &$data = null)
 {
     $path = "";
     foreach ($object->depends->terms as $dep) {
         if ($dep->plural) {
             $path .= TitleUtility::toPlural($dep->term) . "/";
         } else {
             $path .= $dep->term . "/";
         }
         /** represent a term in singular form **/
         $term = TitleUtility::toSingular($dep->term) . "Id";
         if (is_array($data) && array_key_exists($term, $data)) {
             $depid = $data[$term];
             $path .= $depid . "/";
             $object->{$dep->term} = $depid;
             unset($data[$term]);
             /** only set when we're given data **/
             $object->hasPath = true;
         }
     }
     $object->path = $path . $object->path;
 }
コード例 #2
0
ファイル: Base.php プロジェクト: robtro/php-bandwidth
 /**
  * 
  * helper
  * get the path for a given class
  * fallback: plural lowercased
  *
  */
 public function getPath($class)
 {
     if (in_array($class, array_keys(self::$paths))) {
         return self::$paths[$class];
     }
     return strtolower(TitleUtility::toPlural($class));
 }