예제 #1
0
파일: Bucket.php 프로젝트: arvinkx/git-s3
 public function upload(File $file, $metaData)
 {
     try {
         if ($metaData['Content-Encoding']) {
             $this->client->putObject(array('Bucket' => $this->name, 'Key' => $file->getRelativePathname(), 'SourceFile' => $file->getRealpath(), 'ACL' => CannedAcl::PUBLIC_READ, 'ContentEncoding' => $metaData['Content-Encoding']));
         } else {
             $this->client->putObject(array('Bucket' => $this->name, 'Key' => $file->getRelativePathname(), 'SourceFile' => $file->getRealpath(), 'ACL' => CannedAcl::PUBLIC_READ));
         }
     } catch (InstanceProfileCredentialsException $e) {
         throw new InvalidAccessKeyIdException("The AWS Access Key Id you provided does not exist in our records.");
     }
 }
 /**
  * @see ContentModifierInterface::modify()
  */
 public function modify(SplFileInfo $generatedFile, array $data, Inflector $inflector, SplFileInfo $templateFile)
 {
     $options = $this->resolver->resolve($data);
     // retrieve target location
     $targetServicesFilepath = $this->resolveTargetFilePath($options['target'], $generatedFile->getPath());
     // build content
     $import = sprintf('<import resource="%s" />', $inflector->translate($options['resource']));
     $servicesFile = new SplFileInfo($targetServicesFilepath, '', '');
     $servicesContent = $servicesFile->getContents();
     // are services not already registered ?
     if (strpos($servicesContent, $import) !== false) {
         $this->logger->debug(sprintf('Service file "%s" is already registered into "%s". Abording.', $generatedFile->getFilename(), $targetServicesFilepath));
         return $generatedFile->getContents();
     }
     $this->filesystem->dumpFile($servicesFile->getRealpath(), str_replace('    </imports>', sprintf("        %s\n    </imports>", $import), $servicesContent));
     $this->logger->info(sprintf('file updated : %s', $servicesFile->getRealpath()));
     return $generatedFile->getContents();
 }
    /**
     * @see ContentModifierInterface::modify()
     */
    public function modify(SplFileInfo $generatedFile, array $data, Inflector $inflector, SplFileInfo $templateFile)
    {
        $options = $this->resolver->resolve($data);
        // retrieve target location
        $targetRoutingFilepath = $this->resolveTargetFilePath($options['target'], $generatedFile->getPath());
        // build content
        $routing = sprintf('
%s:
    resource: "%s"
    %s', $inflector->translate($options['route']), $inflector->translate($options['resource']), is_null($options['prefix']) ? '' : sprintf("prefix: %s\n", $inflector->translate($options['prefix'])));
        $routingFile = new SplFileInfo($targetRoutingFilepath, '', '');
        $routingContent = $routingFile->getContents();
        // is routing not already registered ?
        if (strpos($routingContent, trim($routing)) !== false) {
            $this->logger->debug(sprintf('Routing file "%s" is already registered into "%s". Abording.', $generatedFile->getFilename(), $targetRoutingFilepath));
            return $generatedFile->getContents();
        }
        $this->filesystem->dumpFile($routingFile->getRealpath(), sprintf('%s%s', $routingContent, $routing));
        $this->logger->info(sprintf('file updated : %s', $routingFile->getRealpath()));
        return $generatedFile->getContents();
    }
예제 #4
0
 /**
  * Computes which configuration handle a config file should bind to.
  *
  * @param SplFileInfo $file
  *
  * @return string
  */
 protected function computeHandleFromPath(SplFileInfo $file)
 {
     // Get realpath
     $handle = $file->getRealpath();
     // Format appropriately
     $handle = str_replace($this->app['path.rocketeer.config'] . DS, null, $handle);
     $handle = str_replace('.php', null, $handle);
     $handle = str_replace(DS, '.', $handle);
     return sprintf('rocketeer::on.%s', $handle);
 }
예제 #5
0
파일: TestRunner.php 프로젝트: phpbb/epv
 /**
  * Try to load and initialise a specific test.
  *
  * @param SplFileInfo $test
  *
  * @throws Exception\TestException
  */
 private function tryToLoadTest(SplFileInfo $test)
 {
     $this->output->writelnIfDebug("<info>Found {$test->getRealpath()}.</info>");
     $file = str_replace('.php', '', basename($test->getRealPath()));
     $class = '\\Phpbb\\Epv\\Tests\\Tests\\' . $file;
     $filetest = new $class($this->debug, $this->output, $this->basedir, $this->namespace, $this->titania, $this->directory);
     if (!$filetest instanceof TestInterface) {
         throw new TestException("{$class} does not implement the TestInterface, but matches the test expression.");
     }
     $this->tests[] = $filetest;
 }