public static function createFromFileBuilder(FileBuilder $builder) { $answer = new static(); foreach ($builder->getFilenames() as $filename) { $file = $builder->getFileObject($filename); $answer->setFileContents($file->getFilename(), $file->getContents()); } return $answer; }
/** * Get local file data. * * @param string $resource * @return \stdClass */ private function localFile($resource) { if (empty($this->localResources[$this->localMode][$resource])) { switch ($this->localMode) { case self::MODE_DIRECT: $data = new \stdClass(); $data->url = ltrim($this->resources[$resource], '/'); $data->filename = sprintf('%s/%s/%s', rtrim(getcwd(), '/'), trim($this->localPrefix['path'], '/'), $data->url); break; case self::MODE_BUILD: $resources = []; foreach (explode(self::BUILD_SEPARATOR, $resource) as $value) { $resources[] = $this->resources[$value]; } $data = $this->fileBuilder->build($resources, $this->localPrefix['path'], $this->localPrefix['build']); break; default: throw new Exceptions\UnknownModeException('Unknown local file mode: ' . $this->localMode); break; } $this->localResources[$this->localMode][$resource] = $data; } return $this->localResources[$this->localMode][$resource]; }