Exemple #1
0
 /**
  * @param PatternInterface $pattern
  */
 protected function addPatternPath(SourcePattern $pattern)
 {
     $path = explode('/', $pattern->getNormalizedPath());
     $type = array_shift($path);
     $name = $this->escapePath(array_pop($path));
     $this->patternPaths[$type][$name] = $this->makeItemPath($pattern);
     ksort($this->patternPaths[$type]);
 }
Exemple #2
0
 public function __construct(PatternInterface $pattern, $variant, $dataFile)
 {
     $this->pattern = $pattern;
     $this->variant = $variant;
     $this->path = $pattern->getPath() . "~{$variant}";
     $this->id = $this->path;
     $this->name = $pattern->getName() . ' ' . str_replace('-', ' ', $variant);
     $this->dataFiles = [$dataFile];
 }
Exemple #3
0
 public function addPattern(\Labcoat\Patterns\PatternInterface $pattern)
 {
     $path = explode(DIRECTORY_SEPARATOR, $pattern->getPath());
     if (count($path) > 2) {
         $this->getSubtype($path[1])->addPattern($pattern);
     } else {
         $this->patterns[$pattern->getSlug()] = new Pattern($pattern);
         foreach ($pattern->getPseudoPatterns() as $pseudo) {
             $this->patterns[$pseudo->getSlug()] = new Pattern($pseudo);
         }
         ksort($this->patterns);
     }
 }
Exemple #4
0
 public function addPattern(PatternInterface $pattern)
 {
     $keys = explode('/', $pattern->getNormalizedPath());
     switch (count($keys)) {
         case 3:
             $subtype = dirname($pattern->getPath());
             $this->getOrCreateSubtype($subtype)->addPattern($pattern);
             break;
         case 2:
             $this->items[$keys[1]] = $pattern;
             break;
         default:
             throw new \InvalidArgumentException("Invalid path");
     }
 }
Exemple #5
0
 public function addPattern(PatternInterface $pattern)
 {
     $this->items[$pattern->getSlug()] = $pattern;
 }
Exemple #6
0
 public function makePath(SourcePattern $pattern)
 {
     $path = Navigation::escapePath($pattern->getPath());
     return PatternLab::makePath([$path, "{$path}.html"]);
 }
Exemple #7
0
 protected function makePaths(SourcePatternInterface $pattern)
 {
     $path = preg_replace('|[\\\\/~]|', '-', $pattern->getPath());
     $this->escapedSourcePath = PatternLab::makePath(['patterns', $path, "{$path}.escaped.html"]);
     $this->path = PatternLab::makePath([$path, "{$path}.html"]);
     $this->pagePath = PatternLab::makePath(['patterns', $this->path]);
     $this->sourcePath = PatternLab::makePath(['patterns', $path, "{$path}.pattern.html"]);
     $this->templatePath = PatternLab::makePath(['patterns', $path, "{$path}.twig"]);
     $this->lineagePath = PatternLab::makePath(['..', '..', $this->pagePath]);
 }