示例#1
0
文件: Loader.php 项目: hason/tabular
 /**
  * Merge any included definitions.
  *
  * @param Definition
  */
 private function processDefinitionIncludes(Definition $definition)
 {
     if (!isset($definition['includes']) || empty($definition['includes'])) {
         return;
     }
     $baseDefinition = array();
     $validKeys = array('rows', 'sort', 'classes', 'params', 'includes');
     foreach ($definition['includes'] as $include) {
         $keys = array();
         if (count($include) == 2) {
             list($file, $keys) = $include;
         } elseif (count($include) == 1) {
             list($file) = $include;
         } else {
             throw new \InvalidArgumentException(sprintf('Invalid number of arguments given for "include" configuration key, got: "%s"', print_r($include, true)));
         }
         if (empty($keys)) {
             $keys = $validKeys;
         }
         $filePath = PathUtil::getPath($file, $definition->getBasePath());
         $includeDefinition = $this->loadDefinition($filePath);
         $baseDefinition = $this->mergeDefinition($baseDefinition, $includeDefinition, $keys);
     }
     $definition->exchangeArray($this->mergeDefinition($baseDefinition, $definition->getArrayCopy(), $validKeys));
 }
示例#2
0
 /**
  * It should return an unmodified absolute path.
  */
 public function testGetPathAbsolute()
 {
     $result = PathUtil::getPath('/path/to/foobar/barfoo', '/path/to');
     $this->assertEquals('/path/to/foobar/barfoo', $result);
 }