diff --git a/.gitignore b/.gitignore index cabea1b5d..8baffc916 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ Resources/doc/_build/* nbproject coverage composer.lock -vendor \ No newline at end of file +vendor +.php_cs.cache diff --git a/.php_cs b/.php_cs new file mode 100644 index 000000000..0b1c7f90e --- /dev/null +++ b/.php_cs @@ -0,0 +1,19 @@ +in(array(__DIR__)) +; + +return Symfony\CS\Config\Config::create() + ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) + ->fixers(array( + '-unalign_double_arrow', + '-unalign_equals', + 'align_double_arrow', + 'newline_after_open_tag', + 'ordered_use', + 'long_array_syntax', + )) + ->setUsingCache(true) + ->finder($finder) +; diff --git a/.travis.yml b/.travis.yml index 38b882f09..a8e27cb55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,8 @@ env: matrix: fast_finish: true include: + - php: 5.6 + env: CS_FIXER=run - php: 5.3 env: COMPOSER_FLAGS="--prefer-lowest" - php: 5.6 @@ -53,7 +55,9 @@ before_script: - export PATH=$HOME/.local/bin:$PATH - pip install -r Resources/doc/requirements.txt --user `whoami` -script: make test +script: + - if [ "$CS_FIXER" = "run" ]; then make cs_dry_run ; fi; + - make test notifications: - webhooks: https://sonata-project.org/bundles/media/master/travis + webhooks: https://sonata-project.org/bundles/media/master/travis diff --git a/Admin/BaseMediaAdmin.php b/Admin/BaseMediaAdmin.php index becb5a310..fd66d1441 100644 --- a/Admin/BaseMediaAdmin.php +++ b/Admin/BaseMediaAdmin.php @@ -12,16 +12,12 @@ namespace Sonata\MediaBundle\Admin; use Sonata\AdminBundle\Admin\Admin; -use Sonata\AdminBundle\Admin\AdminInterface; -use Sonata\AdminBundle\Form\FormMapper; use Sonata\AdminBundle\Datagrid\ListMapper; -use Sonata\AdminBundle\Route\RouteCollection; +use Sonata\AdminBundle\Form\FormMapper; use Sonata\ClassificationBundle\Model\CategoryManagerInterface; use Sonata\CoreBundle\Model\Metadata; -use Sonata\MediaBundle\Provider\Pool; use Sonata\MediaBundle\Form\DataTransformer\ProviderDataTransformer; - -use Knp\Menu\ItemInterface as MenuItemInterface; +use Sonata\MediaBundle\Provider\Pool; abstract class BaseMediaAdmin extends Admin { @@ -90,7 +86,7 @@ protected function configureFormFields(FormMapper $formMapper) 'context' => $media->getContext(), 'hide_context' => true, 'mode' => 'tree', - ) + ), )); } @@ -137,10 +133,10 @@ public function getPersistentParameters() $categoryId = $this->categoryManager->getRootCategory($context)->getId(); } - return array_merge($parameters,array( + return array_merge($parameters, array( 'context' => $context, 'category' => $categoryId, - 'hide_context' => (bool)$this->getRequest()->get('hide_context') + 'hide_context' => (bool) $this->getRequest()->get('hide_context'), )); } diff --git a/Admin/GalleryAdmin.php b/Admin/GalleryAdmin.php index ec45524df..1abd54a31 100644 --- a/Admin/GalleryAdmin.php +++ b/Admin/GalleryAdmin.php @@ -12,9 +12,9 @@ namespace Sonata\MediaBundle\Admin; use Sonata\AdminBundle\Admin\Admin; -use Sonata\AdminBundle\Form\FormMapper; use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Datagrid\ListMapper; +use Sonata\AdminBundle\Form\FormMapper; use Sonata\MediaBundle\Provider\Pool; class GalleryAdmin extends Admin @@ -64,8 +64,8 @@ protected function configureFormFields(FormMapper $formMapper) $formMapper ->with('Options') ->add('context', 'sonata_type_translatable_choice', array( - 'choices' => $contexts, - 'catalogue' => 'SonataMediaBundle' + 'choices' => $contexts, + 'catalogue' => 'SonataMediaBundle', )) ->add('enabled', null, array('required' => false)) ->add('name') @@ -79,7 +79,7 @@ protected function configureFormFields(FormMapper $formMapper) 'inline' => 'table', 'sortable' => 'position', 'link_parameters' => array('context' => $context), - 'admin_code' => 'sonata.media.admin.gallery_has_media' + 'admin_code' => 'sonata.media.admin.gallery_has_media', ) ) ->end() diff --git a/Admin/GalleryHasMediaAdmin.php b/Admin/GalleryHasMediaAdmin.php index 7c36c2241..803886791 100644 --- a/Admin/GalleryHasMediaAdmin.php +++ b/Admin/GalleryHasMediaAdmin.php @@ -12,15 +12,13 @@ namespace Sonata\MediaBundle\Admin; use Sonata\AdminBundle\Admin\Admin; -use Sonata\AdminBundle\Form\FormMapper; use Sonata\AdminBundle\Datagrid\ListMapper; +use Sonata\AdminBundle\Form\FormMapper; class GalleryHasMediaAdmin extends Admin { /** * @param \Sonata\AdminBundle\Form\FormMapper $formMapper - * - * @return void */ protected function configureFormFields(FormMapper $formMapper) { @@ -40,7 +38,7 @@ protected function configureFormFields(FormMapper $formMapper) $formMapper ->add('media', 'sonata_type_model_list', array('required' => false), array( - 'link_parameters' => $link_parameters + 'link_parameters' => $link_parameters, )) ->add('enabled', null, array('required' => false)) ->add('position', 'hidden') @@ -48,8 +46,7 @@ protected function configureFormFields(FormMapper $formMapper) } /** - * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper - * @return void + * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper */ protected function configureListFields(ListMapper $listMapper) { diff --git a/Admin/Manager/DoctrineMongoDBManager.php b/Admin/Manager/DoctrineMongoDBManager.php index 1a6d36a9d..bb740c074 100644 --- a/Admin/Manager/DoctrineMongoDBManager.php +++ b/Admin/Manager/DoctrineMongoDBManager.php @@ -2,12 +2,12 @@ namespace Sonata\MediaBundle\Admin\Manager; -use Sonata\DoctrineMongoDBAdminBundle\Model\ModelManager; use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; +use Sonata\DoctrineMongoDBAdminBundle\Model\ModelManager; /** * this method overwrite the default AdminModelManager to call - * the custom methods from the dedicated media manager + * the custom methods from the dedicated media manager. */ class DoctrineMongoDBManager extends ModelManager { diff --git a/Admin/Manager/DoctrineORMManager.php b/Admin/Manager/DoctrineORMManager.php index 6f2a71f1b..43be0da49 100644 --- a/Admin/Manager/DoctrineORMManager.php +++ b/Admin/Manager/DoctrineORMManager.php @@ -3,15 +3,14 @@ namespace Sonata\MediaBundle\Admin\Manager; use Doctrine\DBAL\DBALException; -use Sonata\DoctrineORMAdminBundle\Model\ModelManager; use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; use Sonata\AdminBundle\Exception\ModelManagerException; - +use Sonata\DoctrineORMAdminBundle\Model\ModelManager; use Symfony\Bridge\Doctrine\RegistryInterface; /** * this method overwrite the default AdminModelManager to call - * the custom methods from the dedicated media manager + * the custom methods from the dedicated media manager. */ class DoctrineORMManager extends ModelManager { @@ -71,12 +70,10 @@ public function delete($object) } /** - * Deletes a set of $class identified by the provided $idx array + * Deletes a set of $class identified by the provided $idx array. * * @param string $class * @param \Sonata\AdminBundle\Datagrid\ProxyQueryInterface $queryProxy - * - * @return void */ public function batchDelete($class, ProxyQueryInterface $queryProxy) { diff --git a/Admin/ODM/MediaAdmin.php b/Admin/ODM/MediaAdmin.php index 5060972a0..96b0d84a6 100644 --- a/Admin/ODM/MediaAdmin.php +++ b/Admin/ODM/MediaAdmin.php @@ -11,14 +11,13 @@ namespace Sonata\MediaBundle\Admin\ODM; -use Sonata\MediaBundle\Admin\BaseMediaAdmin as Admin; use Sonata\AdminBundle\Datagrid\DatagridMapper; +use Sonata\MediaBundle\Admin\BaseMediaAdmin as Admin; class MediaAdmin extends Admin { /** - * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper - * @return void + * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper */ protected function configureDatagridFilters(DatagridMapper $datagridMapper) { diff --git a/Admin/ORM/MediaAdmin.php b/Admin/ORM/MediaAdmin.php index 5943f6723..ef399cbce 100644 --- a/Admin/ORM/MediaAdmin.php +++ b/Admin/ORM/MediaAdmin.php @@ -11,19 +11,18 @@ namespace Sonata\MediaBundle\Admin\ORM; -use Sonata\MediaBundle\Admin\BaseMediaAdmin as Admin; use Sonata\AdminBundle\Datagrid\DatagridMapper; +use Sonata\MediaBundle\Admin\BaseMediaAdmin as Admin; class MediaAdmin extends Admin { /** - * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper - * @return void + * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper */ protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $options = array( - 'choices' => array() + 'choices' => array(), ); foreach ($this->pool->getContexts() as $name => $context) { @@ -35,7 +34,7 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) ->add('providerReference') ->add('enabled') ->add('context', null, array( - 'show_filter' => $this->getPersistentParameter('hide_context') !== true + 'show_filter' => $this->getPersistentParameter('hide_context') !== true, ), 'choice', $options) ->add('category', null, array( 'show_filter' => false, @@ -53,13 +52,13 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) } $datagridMapper->add('providerName', 'doctrine_orm_choice', array( - 'field_options'=> array( - 'choices' => $providers, + 'field_options' => array( + 'choices' => $providers, 'required' => false, 'multiple' => false, 'expanded' => false, ), - 'field_type'=> 'choice', + 'field_type' => 'choice', )); } } diff --git a/Admin/PHPCR/GalleryAdmin.php b/Admin/PHPCR/GalleryAdmin.php index 093f00da5..f06659fd2 100644 --- a/Admin/PHPCR/GalleryAdmin.php +++ b/Admin/PHPCR/GalleryAdmin.php @@ -12,8 +12,8 @@ namespace Sonata\MediaBundle\Admin\PHPCR; use Sonata\AdminBundle\Datagrid\DatagridMapper; -use Sonata\MediaBundle\Admin\GalleryAdmin as BaseGalleryAdmin; use Sonata\AdminBundle\Route\RouteCollection; +use Sonata\MediaBundle\Admin\GalleryAdmin as BaseGalleryAdmin; class GalleryAdmin extends BaseGalleryAdmin { @@ -48,7 +48,6 @@ public function id($object) return $this->getUrlsafeIdentifier($object); } - /** * {@inheritdoc} */ @@ -68,9 +67,9 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) protected function configureRoutes(RouteCollection $collection) { // Allow path in id parameter - $collection->add('view', $this->getRouterIdParameter() . '/view', array(), array('id' => '.+', '_method' => 'GET')); - $collection->add('show', $this->getRouterIdParameter() . '/show', array( - '_controller' => sprintf('%s:%s', $this->baseControllerName, 'view') + $collection->add('view', $this->getRouterIdParameter().'/view', array(), array('id' => '.+', '_method' => 'GET')); + $collection->add('show', $this->getRouterIdParameter().'/show', array( + '_controller' => sprintf('%s:%s', $this->baseControllerName, 'view'), ), array('id' => '.+', '_method' => 'GET') ); diff --git a/Admin/PHPCR/MediaAdmin.php b/Admin/PHPCR/MediaAdmin.php index 2c937d294..da65eb3b0 100644 --- a/Admin/PHPCR/MediaAdmin.php +++ b/Admin/PHPCR/MediaAdmin.php @@ -11,9 +11,9 @@ namespace Sonata\MediaBundle\Admin\PHPCR; -use Sonata\MediaBundle\Admin\BaseMediaAdmin as Admin; use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Route\RouteCollection; +use Sonata\MediaBundle\Admin\BaseMediaAdmin as Admin; class MediaAdmin extends Admin { @@ -49,8 +49,7 @@ public function id($object) } /** - * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper - * @return void + * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper */ protected function configureDatagridFilters(DatagridMapper $datagridMapper) { @@ -69,9 +68,9 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) protected function configureRoutes(RouteCollection $collection) { // Allow path in id parameter - $collection->add('view', $this->getRouterIdParameter() . '/view', array(), array('id' => '.+', '_method' => 'GET')); - $collection->add('show', $this->getRouterIdParameter() . '/show', array( - '_controller' => sprintf('%s:%s', $this->baseControllerName, 'view') + $collection->add('view', $this->getRouterIdParameter().'/view', array(), array('id' => '.+', '_method' => 'GET')); + $collection->add('show', $this->getRouterIdParameter().'/show', array( + '_controller' => sprintf('%s:%s', $this->baseControllerName, 'view'), ), array('id' => '.+', '_method' => 'GET') ); diff --git a/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php b/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php index 3b12732e8..bf35ab9e1 100644 --- a/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php +++ b/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php @@ -15,7 +15,7 @@ use Sonata\SeoBundle\Block\Breadcrumb\BaseBreadcrumbMenuBlockService; /** - * Abstract class for media breadcrumbs + * Abstract class for media breadcrumbs. * * @author Sylvain Deloux */ @@ -30,7 +30,7 @@ protected function getRootMenu(BlockContextInterface $blockContext) $menu->addChild('sonata_media_gallery_index', array( 'route' => 'sonata_media_gallery_index', - 'extras' => array('translation_domain' => 'SonataMediaBundle') + 'extras' => array('translation_domain' => 'SonataMediaBundle'), )); return $menu; diff --git a/Block/FeatureMediaBlockService.php b/Block/FeatureMediaBlockService.php index f462d5504..9103bbb42 100644 --- a/Block/FeatureMediaBlockService.php +++ b/Block/FeatureMediaBlockService.php @@ -1,4 +1,5 @@ */ @@ -39,14 +36,14 @@ public function getName() public function setDefaultSettings(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( - 'media' => false, + 'media' => false, 'orientation' => 'left', - 'title' => false, - 'content' => false, - 'context' => false, - 'mediaId' => null, - 'format' => false, - 'template' => 'SonataMediaBundle:Block:block_feature_media.html.twig' + 'title' => false, + 'content' => false, + 'context' => false, + 'mediaId' => null, + 'format' => false, + 'template' => 'SonataMediaBundle:Block:block_feature_media.html.twig', )); } @@ -65,11 +62,11 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) array('content', 'textarea', array('required' => false)), array('orientation', 'choice', array('choices' => array( 'left' => $translator->trans('feature_left_choice', array(), 'SonataMediaBundle'), - 'right' => $translator->trans('feature_right_choice', array(), 'SonataMediaBundle') + 'right' => $translator->trans('feature_right_choice', array(), 'SonataMediaBundle'), ))), array($this->getMediaBuilder($formMapper), null, array()), array('format', 'choice', array('required' => count($formatChoices) > 0, 'choices' => $formatChoices)), - ) + ), )); } @@ -79,7 +76,7 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) public function getStylesheets($media) { return array( - '/bundles/sonatamedia/blocks/feature_media/theme.css' + '/bundles/sonatamedia/blocks/feature_media/theme.css', ); } } diff --git a/Block/GalleryBlockService.php b/Block/GalleryBlockService.php index 356a86f30..8eb5e64a7 100644 --- a/Block/GalleryBlockService.php +++ b/Block/GalleryBlockService.php @@ -1,4 +1,5 @@ */ @@ -84,7 +82,6 @@ public function getGalleryAdmin() */ public function validateBlock(ErrorElement $errorElement, BlockInterface $block) { - } /** @@ -101,7 +98,7 @@ public function setDefaultSettings(OptionsResolverInterface $resolver) 'startPaused' => false, 'wrap' => true, 'template' => 'SonataMediaBundle:Block:block_gallery.html.twig', - 'galleryId' => null + 'galleryId' => null, )); } @@ -121,7 +118,6 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) $formatChoices = array(); if ($gallery instanceof GalleryInterface) { - $formats = $this->getMediaPool()->getFormatNamesByContext($gallery->getContext()); foreach ($formats as $code => $format) { @@ -130,7 +126,7 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) } // simulate an association ... - $fieldDescription = $this->getGalleryAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->getGalleryAdmin()->getClass(), 'media' ); + $fieldDescription = $this->getGalleryAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->getGalleryAdmin()->getClass(), 'media'); $fieldDescription->setAssociationAdmin($this->getGalleryAdmin()); $fieldDescription->setAdmin($formMapper->getAdmin()); $fieldDescription->setOption('edit', 'list'); @@ -138,8 +134,8 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) $builder = $formMapper->create('galleryId', 'sonata_type_model_list', array( 'sonata_field_description' => $fieldDescription, - 'class' => $this->getGalleryAdmin()->getClass(), - 'model_manager' => $this->getGalleryAdmin()->getModelManager() + 'class' => $this->getGalleryAdmin()->getClass(), + 'model_manager' => $this->getGalleryAdmin()->getModelManager(), )); $formMapper->add('settings', 'sonata_type_immutable_array', array( @@ -151,7 +147,7 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) array('pauseTime', 'number', array()), array('startPaused', 'sonata_type_boolean', array()), array('wrap', 'sonata_type_boolean', array()), - ) + ), )); } diff --git a/Block/MediaBlockService.php b/Block/MediaBlockService.php index 7a001e992..774cf5ff4 100644 --- a/Block/MediaBlockService.php +++ b/Block/MediaBlockService.php @@ -1,4 +1,5 @@ */ @@ -89,7 +86,7 @@ public function setDefaultSettings(OptionsResolverInterface $resolver) 'context' => false, 'mediaId' => null, 'format' => false, - 'template' => 'SonataMediaBundle:Block:block_media.html.twig' + 'template' => 'SonataMediaBundle:Block:block_media.html.twig', )); } @@ -109,7 +106,7 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) array('title', 'text', array('required' => false)), array($this->getMediaBuilder($formMapper), null, array()), array('format', 'choice', array('required' => count($formatChoices) > 0, 'choices' => $formatChoices)), - ) + ), )); } @@ -149,13 +146,13 @@ protected function getMediaBuilder(FormMapper $formMapper) $fieldDescription->setOption('edit', 'list'); $fieldDescription->setAssociationMapping(array( 'fieldName' => 'media', - 'type' => \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_ONE + 'type' => \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_ONE, )); return $formMapper->create('mediaId', 'sonata_type_model_list', array( 'sonata_field_description' => $fieldDescription, 'class' => $this->getMediaAdmin()->getClass(), - 'model_manager' => $this->getMediaAdmin()->getModelManager() + 'model_manager' => $this->getMediaAdmin()->getModelManager(), )); } @@ -177,7 +174,7 @@ public function execute(BlockContextInterface $blockContext, Response $response return $this->renderResponse($blockContext->getTemplate(), array( 'media' => $blockContext->getSetting('mediaId'), 'block' => $blockContext->getBlock(), - 'settings' => $blockContext->getSettings() + 'settings' => $blockContext->getSettings(), ), $response); } diff --git a/CDN/CDNInterface.php b/CDN/CDNInterface.php index 36211450c..893f48038 100644 --- a/CDN/CDNInterface.php +++ b/CDN/CDNInterface.php @@ -20,17 +20,17 @@ interface CDNInterface const STATUS_WAITING = 5; /** - * Return the base path + * Return the base path. * - * @param string $relativePath - * @param boolean $isFlushable + * @param string $relativePath + * @param bool $isFlushable * * @return string */ public function getPath($relativePath, $isFlushable); /** - * Flush the resource + * Flush the resource. * * @param string $string * @@ -39,7 +39,7 @@ public function getPath($relativePath, $isFlushable); public function flush($string); /** - * Flush a set of resources matching the provided string + * Flush a set of resources matching the provided string. * * @param string $string * @@ -48,7 +48,7 @@ public function flush($string); public function flushByString($string); /** - * Flush a set of resources matching the paths in provided array + * Flush a set of resources matching the paths in provided array. * * @param array $paths * @@ -57,9 +57,9 @@ public function flushByString($string); public function flushPaths(array $paths); /** - * Return the CDN status for given identifier + * Return the CDN status for given identifier. * - * @param string $identifier + * @param string $identifier * * @return string */ diff --git a/CDN/CloudFront.php b/CDN/CloudFront.php index 5b35647bf..ef3911b16 100644 --- a/CDN/CloudFront.php +++ b/CDN/CloudFront.php @@ -1,4 +1,5 @@ */ class CloudFront implements CDNInterface @@ -116,32 +118,32 @@ public function flushPaths(array $paths) } // Normalizes paths due possible typos since all the CloudFront's // objects starts with a leading slash - $normalizedPaths = array_map(function($path) { - return '/' . ltrim($path, '/'); + $normalizedPaths = array_map(function ($path) { + return '/'.ltrim($path, '/'); }, $paths); try { $result = $this->getClient()->createInvalidation(array( 'DistributionId' => $this->distributionId, - 'Paths' => array( + 'Paths' => array( 'Quantity' => count($normalizedPaths), - 'Items' => $normalizedPaths + 'Items' => $normalizedPaths, ), 'CallerReference' => $this->getCallerReference($normalizedPaths), )); if (!in_array($status = $result->get('Status'), array('Completed', 'InProgress'))) { - throw new \RuntimeException('Unable to flush : ' . $status); + throw new \RuntimeException('Unable to flush : '.$status); } return $result->get('Id'); } catch (CloudFrontException $ex) { - throw new \RuntimeException('Unable to flush : ' . $ex->getMessage()); + throw new \RuntimeException('Unable to flush : '.$ex->getMessage()); } } /** - * Return a CloudFrontClient + * Return a CloudFrontClient. * * @return CloudFrontClient */ @@ -150,7 +152,7 @@ private function getClient() if (!$this->client) { $this->client = CloudFrontClient::factory(array( 'key' => $this->key, - 'secret' => $this->secret + 'secret' => $this->secret, )); } @@ -158,11 +160,9 @@ private function getClient() } /** - * For testing only + * For testing only. * * @param $client - * - * @return void */ public function setClient($client) { @@ -170,9 +170,10 @@ public function setClient($client) } /** - * Generates a valid caller reference from given paths regardless its order + * Generates a valid caller reference from given paths regardless its order. * * @param array $paths + * * @return string a md5 representation */ protected function getCallerReference(array $paths) @@ -192,17 +193,18 @@ public function getFlushStatus($identifier) try { $result = $this->getClient()->getInvalidation(array( 'DistributionId' => $this->distributionId, - 'Id' => $identifier + 'Id' => $identifier, )); return array_search($result->get('Status'), self::getStatusList()); } catch (CloudFrontException $ex) { - throw new \RuntimeException('Unable to retrieve flush status : ' . $ex->getMessage()); + throw new \RuntimeException('Unable to retrieve flush status : '.$ex->getMessage()); } } /** * @static + * * @return array */ public static function getStatusList() diff --git a/CDN/PantherPortal.php b/CDN/PantherPortal.php index ca73346ca..86fd10e13 100644 --- a/CDN/PantherPortal.php +++ b/CDN/PantherPortal.php @@ -1,4 +1,5 @@ path = $path; $this->username = $username; @@ -87,15 +87,15 @@ public function flush($string) */ public function flushPaths(array $paths) { - $result = $this->getClient()->flush($this->username, $this->password, "paths", $this->siteId, implode("\n", $paths), true, false); + $result = $this->getClient()->flush($this->username, $this->password, 'paths', $this->siteId, implode("\n", $paths), true, false); - if ($result != "Flush successfully submitted.") { - throw new \RuntimeException('Unable to flush : ' . $result); + if ($result != 'Flush successfully submitted.') { + throw new \RuntimeException('Unable to flush : '.$result); } } /** - * Return a SoapClient + * Return a SoapClient. * * @return \SoapClient */ @@ -109,11 +109,9 @@ private function getClient() } /** - * For testing only + * For testing only. * * @param $client - * - * @return void */ public function setClient($client) { diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 06ae638d0..044c54c27 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,13 +14,29 @@ Then, if it appears that it’s a real bug, you may report it using Github by fo > _NOTE:_ Don’t hesitate giving as much information as you can (OS, PHP version extensions …) -## Sending a Pull Request +## Pull requests + +### Matching coding standards + +Before each commit, be sure to match sonata coding standards by running the following command for fix: + +```bash +make cs +``` + +And then, add fixed file to your commit before push. + +Be sure to add only **your modified files**. If another files are fixed by cs tools, just revert it before commit. + +### Sending a Pull Request When you send a PR, just make sure that: * You add valid test cases. * Tests are green. * The related documentation is up-to-date. +* You make the PR on the same branch you based your changes on. If you see commits +that you did not make in your PR, you're doing it wrong. * Also don't forget to add a comment when you update a PR with a ping to the maintainer (``@username``), so he/she will get a notification. ## Contributing to the documentation diff --git a/Command/AddMassMediaCommand.php b/Command/AddMassMediaCommand.php index fa783a093..88e36d09d 100644 --- a/Command/AddMassMediaCommand.php +++ b/Command/AddMassMediaCommand.php @@ -11,9 +11,9 @@ namespace Sonata\MediaBundle\Command; +use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; class AddMassMediaCommand extends BaseCommand { @@ -48,7 +48,7 @@ public function execute(InputInterface $input, OutputInterface $output) if ($imported === -1) { $this->setters = $data; - $imported++; + ++$imported; continue; } @@ -56,13 +56,13 @@ public function execute(InputInterface $input, OutputInterface $output) continue; } - $imported++; + ++$imported; $this->insertMedia($data, $output); $this->optimize(); } - $output->writeln("Done!"); + $output->writeln('Done!'); } /** diff --git a/Command/AddMediaCommand.php b/Command/AddMediaCommand.php index 9013f0d68..9f90d8b97 100644 --- a/Command/AddMediaCommand.php +++ b/Command/AddMediaCommand.php @@ -11,10 +11,10 @@ namespace Sonata\MediaBundle\Command; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; class AddMediaCommand extends BaseCommand { @@ -49,7 +49,7 @@ public function execute(InputInterface $input, OutputInterface $output) $context = $input->getArgument('context'); $binaryContent = $input->getArgument('binaryContent'); - $output->writeln(sprintf("Add a new media - context: %s, provider: %s, content: %s", $context, $provider, $binaryContent)); + $output->writeln(sprintf('Add a new media - context: %s, provider: %s, content: %s', $context, $provider, $binaryContent)); $media = $this->getMediaManager()->create(); $media->setBinaryContent($binaryContent); @@ -74,6 +74,6 @@ public function execute(InputInterface $input, OutputInterface $output) $this->getMediaManager()->save($media, $context, $provider); - $output->writeln("done!"); + $output->writeln('done!'); } } diff --git a/Command/BaseCommand.php b/Command/BaseCommand.php index 6fcf410a8..631734eec 100644 --- a/Command/BaseCommand.php +++ b/Command/BaseCommand.php @@ -17,7 +17,6 @@ * This command can be used to re-generate the thumbnails for all uploaded medias. * * Useful if you have existing media content and added new formats. - * */ abstract class BaseCommand extends ContainerAwareCommand { diff --git a/Command/MigrateToJsonTypeCommand.php b/Command/MigrateToJsonTypeCommand.php index 63b7442c0..d80d08b5c 100644 --- a/Command/MigrateToJsonTypeCommand.php +++ b/Command/MigrateToJsonTypeCommand.php @@ -11,10 +11,9 @@ namespace Sonata\MediaBundle\Command; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\Output; class MigrateToJsonTypeCommand extends BaseCommand { @@ -41,7 +40,7 @@ public function execute(InputInterface $input, OutputInterface $output) if (0 !== strpos($media[$column], '{') && $media[$column] !== '[]') { $media[$column] = json_encode(unserialize($media[$column])); $connection->update($table, array($column => $media[$column]), array($columnId => $media[$columnId])); - $count++; + ++$count; } } diff --git a/Command/RefreshMetadataCommand.php b/Command/RefreshMetadataCommand.php index 2ea62ffdf..96a25d3f7 100644 --- a/Command/RefreshMetadataCommand.php +++ b/Command/RefreshMetadataCommand.php @@ -12,15 +12,13 @@ namespace Sonata\MediaBundle\Command; use Symfony\Component\Console\Input\InputArgument; - -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; /** * This command can be used to re-generate the thumbnails for all uploaded medias. * * Useful if you have existing media content and added new formats. - * */ class RefreshMetadataCommand extends BaseCommand { @@ -65,27 +63,27 @@ public function execute(InputInterface $input, OutputInterface $output) $medias = $this->getMediaManager()->findBy(array( 'providerName' => $provider, - 'context' => $context + 'context' => $context, )); - $this->log(sprintf("Loaded %s medias for generating thumbs (provider: %s, context: %s)", count($medias), $provider, $context)); + $this->log(sprintf('Loaded %s medias for generating thumbs (provider: %s, context: %s)', count($medias), $provider, $context)); foreach ($medias as $media) { $provider = $this->getMediaPool()->getProvider($media->getProviderName()); - $this->log("Refresh media " . $media->getName() . ' - ' . $media->getId()); + $this->log('Refresh media '.$media->getName().' - '.$media->getId()); try { $provider->updateMetadata($media, false); } catch (\Exception $e) { - $this->log(sprintf("Unable to update metadata, media: %s - %s ", $media->getId(), $e->getMessage())); + $this->log(sprintf('Unable to update metadata, media: %s - %s ', $media->getId(), $e->getMessage())); continue; } try { $this->getMediaManager()->save($media); } catch (\Exception $e) { - $this->log(sprintf("Unable saving media, media: %s - %s ", $media->getId(), $e->getMessage())); + $this->log(sprintf('Unable saving media, media: %s - %s ', $media->getId(), $e->getMessage())); continue; } } @@ -94,11 +92,9 @@ public function execute(InputInterface $input, OutputInterface $output) } /** - * Write a message to the output + * Write a message to the output. * * @param string $message - * - * @return void */ protected function log($message) { diff --git a/Command/RemoveThumbsCommand.php b/Command/RemoveThumbsCommand.php index d23cc57c3..d248c8627 100644 --- a/Command/RemoveThumbsCommand.php +++ b/Command/RemoveThumbsCommand.php @@ -11,18 +11,17 @@ namespace Sonata\MediaBundle\Command; +use Sonata\MediaBundle\Model\MediaInterface; +use Sonata\MediaBundle\Provider\MediaProviderInterface; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; -use Sonata\MediaBundle\Provider\MediaProviderInterface; -use Sonata\MediaBundle\Model\MediaInterface; /** * This command can be used to re-generate the thumbnails for all uploaded medias. * * Useful if you have existing media content and added new formats. - * */ class RemoveThumbsCommand extends BaseCommand { @@ -54,7 +53,7 @@ public function configure() new InputArgument('format', InputArgument::OPTIONAL, 'The format (pass `all` to delete all thumbs)'), new InputOption('batchSize', null, InputOption::VALUE_REQUIRED, 'Media batch size (100 by default)', 100), new InputOption('batchesLimit', null, InputOption::VALUE_REQUIRED, 'Media batches limit (0 by default)', 0), - new InputOption('startOffset', null, InputOption::VALUE_REQUIRED, 'Medias start offset (0 by default)', 0) + new InputOption('startOffset', null, InputOption::VALUE_REQUIRED, 'Medias start offset (0 by default)', 0), ) ); } @@ -85,22 +84,22 @@ public function execute(InputInterface $input, OutputInterface $output) $startOffset = intval($input->getOption('startOffset')); $totalMediasCount = 0; do { - $batchCounter++; + ++$batchCounter; try { $batchOffset = $startOffset + ($batchCounter - 1) * $batchSize; $medias = $this->getMediaManager()->findBy( array( 'providerName' => $provider->getName(), - 'context' => $context + 'context' => $context, ), array( - 'id' => 'ASC' + 'id' => 'ASC', ), $batchSize, $batchOffset ); } catch (\Exception $e) { - $this->log('Error: ' . $e->getMessage()); + $this->log('Error: '.$e->getMessage()); break; } @@ -112,7 +111,7 @@ public function execute(InputInterface $input, OutputInterface $output) $totalMediasCount += $batchMediasCount; $this->log( sprintf( - "Loaded %s medias (batch #%d, offset %d) for removing thumbs (provider: %s, format: %s)", + 'Loaded %s medias (batch #%d, offset %d) for removing thumbs (provider: %s, format: %s)', $batchMediasCount, $batchCounter, $batchOffset, @@ -174,7 +173,7 @@ public function getContext() /** * @param MediaProviderInterface $provider - * @param string $context + * @param string $context * * @return mixed|string */ @@ -189,10 +188,10 @@ public function getFormat(MediaProviderInterface $provider, $context) $formatKey = $dialog->select($this->output, 'Please select the format', $formats); $format = $formats[$formatKey]; if ($format === '') { - $format = $context . '_all'; + $format = $context.'_all'; } } else { - $format = $context . '_' . $format; + $format = $context.'_'.$format; } return $format; @@ -208,17 +207,18 @@ public function getFormat(MediaProviderInterface $provider, $context) */ protected function processMedia(MediaInterface $media, MediaProviderInterface $provider, $context, $format) { - $this->log("Deleting thumbs for " . $media->getName() . ' - ' . $media->getId()); + $this->log('Deleting thumbs for '.$media->getName().' - '.$media->getId()); try { - if ($format === $context . '_all') { + if ($format === $context.'_all') { $format = null; } $provider->removeThumbnails($media, $format); } catch (\Exception $e) { - $this->log(sprintf("Unable to remove thumbnails, media: %s - %s ", + $this->log(sprintf('Unable to remove thumbnails, media: %s - %s ', $media->getId(), $e->getMessage())); + return false; } @@ -226,11 +226,9 @@ protected function processMedia(MediaInterface $media, MediaProviderInterface $p } /** - * Write a message to the output + * Write a message to the output. * * @param string $message - * - * @return void */ protected function log($message) { diff --git a/Command/SyncThumbsCommand.php b/Command/SyncThumbsCommand.php index ac4fdfb53..e86e2fd64 100644 --- a/Command/SyncThumbsCommand.php +++ b/Command/SyncThumbsCommand.php @@ -12,16 +12,14 @@ namespace Sonata\MediaBundle\Command; use Symfony\Component\Console\Input\InputArgument; - +use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; /** * This command can be used to re-generate the thumbnails for all uploaded medias. * * Useful if you have existing media content and added new formats. - * */ class SyncThumbsCommand extends BaseCommand { @@ -40,7 +38,7 @@ public function configure() new InputArgument('context', InputArgument::OPTIONAL, 'The context'), new InputOption('batchSize', null, InputOption::VALUE_REQUIRED, 'Media batch size (100 by default)', 100), new InputOption('batchesLimit', null, InputOption::VALUE_REQUIRED, 'Media batches limit (0 by default)', 0), - new InputOption('startOffset', null, InputOption::VALUE_REQUIRED, 'Medias start offset (0 by default)', 0) + new InputOption('startOffset', null, InputOption::VALUE_REQUIRED, 'Medias start offset (0 by default)', 0), ) ); } @@ -80,22 +78,22 @@ public function execute(InputInterface $input, OutputInterface $output) $startOffset = intval($input->getOption('startOffset')); $totalMediasCount = 0; do { - $batchCounter++; + ++$batchCounter; try { $batchOffset = $startOffset + ($batchCounter - 1) * $batchSize; $medias = $this->getMediaManager()->findBy( array( 'providerName' => $providerName, - 'context' => $context + 'context' => $context, ), array( - 'id' => 'ASC' + 'id' => 'ASC', ), $batchSize, $batchOffset ); } catch (\Exception $e) { - $this->log('Error: ' . $e->getMessage()); + $this->log('Error: '.$e->getMessage()); break; } @@ -107,7 +105,7 @@ public function execute(InputInterface $input, OutputInterface $output) $totalMediasCount += $batchMediasCount; $this->log( sprintf( - "Loaded %s medias (batch #%d, offset %d) for generating thumbs (provider: %s, context: %s)", + 'Loaded %s medias (batch #%d, offset %d) for generating thumbs (provider: %s, context: %s)', $batchMediasCount, $batchCounter, $batchOffset, @@ -136,28 +134,30 @@ public function execute(InputInterface $input, OutputInterface $output) } /** - * @param \Sonata\MediaBundle\Model\MediaInterface $media + * @param \Sonata\MediaBundle\Model\MediaInterface $media * @param \Sonata\MediaBundle\Provider\MediaProviderInterface $provider * * @return bool */ protected function processMedia($media, $provider) { - $this->log("Generating thumbs for " . $media->getName() . ' - ' . $media->getId()); + $this->log('Generating thumbs for '.$media->getName().' - '.$media->getId()); try { $provider->removeThumbnails($media); } catch (\Exception $e) { - $this->log(sprintf("Unable to remove old thumbnails, media: %s - %s ", + $this->log(sprintf('Unable to remove old thumbnails, media: %s - %s ', $media->getId(), $e->getMessage())); + return false; } try { $provider->generateThumbnails($media); } catch (\Exception $e) { - $this->log(sprintf("Unable to generate new thumbnails, media: %s - %s ", + $this->log(sprintf('Unable to generate new thumbnails, media: %s - %s ', $media->getId(), $e->getMessage())); + return false; } @@ -165,11 +165,9 @@ protected function processMedia($media, $provider) } /** - * Write a message to the output + * Write a message to the output. * * @param string $message - * - * @return void */ protected function log($message) { diff --git a/Command/UpdateCdnStatusCommand.php b/Command/UpdateCdnStatusCommand.php index b2c2666cc..5a7dbcaf3 100644 --- a/Command/UpdateCdnStatusCommand.php +++ b/Command/UpdateCdnStatusCommand.php @@ -1,6 +1,6 @@ @@ -66,10 +66,10 @@ public function execute(InputInterface $input, OutputInterface $output) $medias = $this->getMediaManager()->findBy(array( 'providerName' => $provider, 'context' => $context, - 'cdnIsFlushable' => true + 'cdnIsFlushable' => true, )); - $this->log(sprintf("Loaded %s medias for updating CDN status (provider: %s, context: %s)", count($medias), $provider, $context)); + $this->log(sprintf('Loaded %s medias for updating CDN status (provider: %s, context: %s)', count($medias), $provider, $context)); foreach ($medias as $media) { $cdn = $this->getMediaPool()->getProvider($media->getProviderName())->getCdn(); @@ -93,7 +93,7 @@ public function execute(InputInterface $input, OutputInterface $output) if (OutputInterface::VERBOSITY_VERBOSE <= $this->output->getVerbosity()) { if ($previousStatus == $cdnStatus) { $this->log(sprintf('No changes (%d)', $cdnStatus)); - } elseif(CDNInterface::STATUS_OK === $cdnStatus) { + } elseif (CDNInterface::STATUS_OK === $cdnStatus) { $this->log(sprintf('Flush completed (%d => %d)', $previousStatus, $cdnStatus)); } else { $this->log(sprintf('Updated status (%d => %d)', $previousStatus, $cdnStatus)); @@ -116,11 +116,9 @@ public function execute(InputInterface $input, OutputInterface $output) } /** - * Write a message to the output + * Write a message to the output. * * @param string $message - * - * @return void */ protected function log($message, $newLine = true) { diff --git a/Consumer/CreateThumbnailConsumer.php b/Consumer/CreateThumbnailConsumer.php index 9e3954702..5d9611542 100644 --- a/Consumer/CreateThumbnailConsumer.php +++ b/Consumer/CreateThumbnailConsumer.php @@ -11,13 +11,12 @@ namespace Sonata\MediaBundle\Consumer; -use Sonata\NotificationBundle\Consumer\ConsumerInterface; -use Sonata\NotificationBundle\Consumer\ConsumerEvent; use Sonata\CoreBundle\Model\ManagerInterface; use Sonata\MediaBundle\Provider\Pool; use Sonata\MediaBundle\Thumbnail\ThumbnailInterface; +use Sonata\NotificationBundle\Consumer\ConsumerEvent; +use Sonata\NotificationBundle\Consumer\ConsumerInterface; use Sonata\NotificationBundle\Exception\HandlingException; - use Symfony\Component\DependencyInjection\ContainerInterface; class CreateThumbnailConsumer implements ConsumerInterface @@ -46,7 +45,7 @@ public function __construct(ManagerInterface $mediaManager, Pool $pool, Containe public function process(ConsumerEvent $event) { $media = $this->mediaManager->findOneBy(array( - 'id' => $event->getMessage()->getValue('mediaId') + 'id' => $event->getMessage()->getValue('mediaId'), )); if (!$media) { diff --git a/Controller/Api/GalleryController.php b/Controller/Api/GalleryController.php index 1c86352b5..17c2fc5c4 100644 --- a/Controller/Api/GalleryController.php +++ b/Controller/Api/GalleryController.php @@ -1,4 +1,5 @@ */ @@ -59,7 +57,7 @@ class GalleryController protected $galleryHasMediaClass; /** - * Constructor + * Constructor. * * @param GalleryManagerInterface $galleryManager * @param MediaManagerInterface $mediaManager @@ -75,7 +73,7 @@ public function __construct(GalleryManagerInterface $galleryManager, MediaManage } /** - * Retrieves the list of galleries (paginated) + * Retrieves the list of galleries (paginated). * * @ApiDoc( * resource=true, @@ -96,7 +94,7 @@ public function __construct(GalleryManagerInterface $galleryManager, MediaManage public function getGalleriesAction(ParamFetcherInterface $paramFetcher) { $supportedCriteria = array( - 'enabled' => "", + 'enabled' => '', ); $page = $paramFetcher->get('page'); @@ -107,7 +105,7 @@ public function getGalleriesAction(ParamFetcherInterface $paramFetcher) foreach ($criteria as $key => $value) { if (null === $value) { unset($criteria[$key]); - } + } } if (!$sort) { @@ -120,7 +118,7 @@ public function getGalleriesAction(ParamFetcherInterface $paramFetcher) } /** - * Retrieves a specific gallery + * Retrieves a specific gallery. * * @ApiDoc( * requirements={ @@ -145,7 +143,7 @@ public function getGalleryAction($id) } /** - * Retrieves the medias of specified gallery + * Retrieves the medias of specified gallery. * * @ApiDoc( * requirements={ @@ -177,7 +175,7 @@ public function getGalleryMediasAction($id) } /** - * Retrieves the galleryhasmedias of specified gallery + * Retrieves the galleryhasmedias of specified gallery. * * @ApiDoc( * requirements={ @@ -202,7 +200,7 @@ public function getGalleryGalleryhasmediasAction($id) } /** - * Adds a gallery + * Adds a gallery. * * @ApiDoc( * input={"class"="sonata_media_api_form_gallery", "name"="", "groups"={"sonata_api_write"}}, @@ -225,7 +223,7 @@ public function postGalleryAction(Request $request) } /** - * Updates a gallery + * Updates a gallery. * * @ApiDoc( * requirements={ @@ -253,7 +251,7 @@ public function putGalleryAction($id, Request $request) } /** - * Adds a media to a gallery + * Adds a media to a gallery. * * @ApiDoc( * requirements={ @@ -268,11 +266,10 @@ public function putGalleryAction($id, Request $request) * } * ) * - * @param integer $galleryId A gallery identifier - * @param integer $mediaId A media identifier + * @param int $galleryId A gallery identifier + * @param int $mediaId A media identifier + * @param Request $request A Symfony request * - * @param Request $request A Symfony request - * @return GalleryInterface * * @throws NotFoundHttpException @@ -285,7 +282,7 @@ public function postGalleryMediaGalleryhasmediaAction($galleryId, $mediaId, Requ foreach ($gallery->getGalleryHasMedias() as $galleryHasMedia) { if ($galleryHasMedia->getMedia()->getId() == $media->getId()) { return FOSRestView::create(array( - 'error' => sprintf('Gallery "%s" already has media "%s"', $galleryId, $mediaId) + 'error' => sprintf('Gallery "%s" already has media "%s"', $galleryId, $mediaId), ), 400); } } @@ -294,7 +291,7 @@ public function postGalleryMediaGalleryhasmediaAction($galleryId, $mediaId, Requ } /** - * Updates a media to a gallery + * Updates a media to a gallery. * * @ApiDoc( * requirements={ @@ -309,11 +306,10 @@ public function postGalleryMediaGalleryhasmediaAction($galleryId, $mediaId, Requ * } * ) * - * @param integer $galleryId A gallery identifier - * @param integer $mediaId A media identifier + * @param int $galleryId A gallery identifier + * @param int $mediaId A media identifier + * @param Request $request A Symfony request * - * @param Request $request A Symfony request - * @return GalleryInterface * * @throws NotFoundHttpException @@ -333,19 +329,19 @@ public function putGalleryMediaGalleryhasmediaAction($galleryId, $mediaId, Reque } /** - * Write a GalleryHasMedia, this method is used by both POST and PUT action methods + * Write a GalleryHasMedia, this method is used by both POST and PUT action methods. * - * @param GalleryInterface $gallery - * @param MediaInterface $media + * @param GalleryInterface $gallery + * @param MediaInterface $media * @param GalleryHasMediaInterface $galleryHasMedia - * @param Request $request + * @param Request $request * * @return FOSRestView|\Symfony\Component\Form\FormInterface */ protected function handleWriteGalleryhasmedia(GalleryInterface $gallery, MediaInterface $media, GalleryHasMediaInterface $galleryHasMedia = null, Request $request) { $form = $this->formFactory->createNamed(null, 'sonata_media_api_form_gallery_has_media', $galleryHasMedia, array( - 'csrf_protection' => false + 'csrf_protection' => false, )); $form->bind($request); @@ -370,7 +366,7 @@ protected function handleWriteGalleryhasmedia(GalleryInterface $gallery, MediaIn } /** - * Deletes a media association to a gallery + * Deletes a media association to a gallery. * * @ApiDoc( * requirements={ @@ -384,8 +380,8 @@ protected function handleWriteGalleryhasmedia(GalleryInterface $gallery, MediaIn * } * ) * - * @param integer $galleryId A gallery identifier - * @param integer $mediaId A media identifier + * @param int $galleryId A gallery identifier + * @param int $mediaId A media identifier * * @return \FOS\RestBundle\View\View * @@ -406,12 +402,12 @@ public function deleteGalleryMediaGalleryhasmediaAction($galleryId, $mediaId) } return FOSRestView::create(array( - 'error' => sprintf('Gallery "%s" does not have media "%s" associated', $galleryId, $mediaId) + 'error' => sprintf('Gallery "%s" does not have media "%s" associated', $galleryId, $mediaId), ), 400); } /** - * Deletes a gallery + * Deletes a gallery. * * @ApiDoc( * requirements={ @@ -424,7 +420,7 @@ public function deleteGalleryMediaGalleryhasmediaAction($galleryId, $mediaId) * } * ) * - * @param integer $id A Gallery identifier + * @param int $id A Gallery identifier * * @return \FOS\RestBundle\View\View * @@ -440,11 +436,12 @@ public function deleteGalleryAction($id) } /** - * Retrieves gallery with id $id or throws an exception if it doesn't exist + * Retrieves gallery with id $id or throws an exception if it doesn't exist. * * @param $id * * @return Gallery + * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ protected function getGallery($id) @@ -459,11 +456,12 @@ protected function getGallery($id) } /** - * Retrieves media with id $id or throws an exception if it doesn't exist + * Retrieves media with id $id or throws an exception if it doesn't exist. * * @param $id * * @return Media + * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ protected function getMedia($id) @@ -494,10 +492,10 @@ protected function getMediaManager() } /** - * Write a Gallery, this method is used by both POST and PUT action methods + * Write a Gallery, this method is used by both POST and PUT action methods. * - * @param Request $request Symfony request - * @param integer|null $id A Gallery identifier + * @param Request $request Symfony request + * @param int|null $id A Gallery identifier * * @return \FOS\RestBundle\View\View|FormInterface */ @@ -506,7 +504,7 @@ protected function handleWriteGallery($request, $id = null) $gallery = $id ? $this->getGallery($id) : null; $form = $this->formFactory->createNamed(null, 'sonata_media_api_form_gallery', $gallery, array( - 'csrf_protection' => false + 'csrf_protection' => false, )); $form->bind($request); diff --git a/Controller/Api/MediaController.php b/Controller/Api/MediaController.php index beb010407..c611fd585 100644 --- a/Controller/Api/MediaController.php +++ b/Controller/Api/MediaController.php @@ -1,4 +1,5 @@ */ @@ -56,7 +53,7 @@ class MediaController protected $formFactory; /** - * Constructor + * Constructor. * * @param MediaManagerInterface $mediaManager * @param Pool $mediaPool @@ -70,7 +67,7 @@ public function __construct(MediaManagerInterface $mediaManager, Pool $mediaPool } /** - * Retrieves the list of medias (paginated) + * Retrieves the list of medias (paginated). * * @ApiDoc( * resource=true, @@ -91,7 +88,7 @@ public function __construct(MediaManagerInterface $mediaManager, Pool $mediaPool public function getMediaAction(ParamFetcherInterface $paramFetcher) { $supportedCriteria = array( - 'enabled' => "", + 'enabled' => '', ); $page = $paramFetcher->get('page'); @@ -115,7 +112,7 @@ public function getMediaAction(ParamFetcherInterface $paramFetcher) } /** - * Retrieves a specific media + * Retrieves a specific media. * * @ApiDoc( * requirements={ @@ -140,7 +137,7 @@ public function getMediumAction($id) } /** - * Returns media urls for each format + * Returns media urls for each format. * * @ApiDoc( * requirements={ @@ -175,7 +172,7 @@ public function getMediumFormatsAction($id) } /** - * Returns media binary content for each format + * Returns media binary content for each format. * * @ApiDoc( * requirements={ @@ -188,8 +185,8 @@ public function getMediumFormatsAction($id) * } * ) * - * @param integer $id The media id - * @param string $format The format + * @param int $id The media id + * @param string $format The format * @param Request $request * * @return \Symfony\Component\HttpFoundation\Response @@ -208,7 +205,7 @@ public function getMediumBinaryAction($id, $format, Request $request) } /** - * Deletes a medium + * Deletes a medium. * * @ApiDoc( * requirements={ @@ -221,7 +218,7 @@ public function getMediumBinaryAction($id, $format, Request $request) * } * ) * - * @param integer $id A medium identifier + * @param int $id A medium identifier * * @return \FOS\RestBundle\View\View * @@ -239,7 +236,7 @@ public function deleteMediumAction($id) /** * Updates a medium * If you need to upload a file (depends on the provider) you will need to do so by sending content as a multipart/form-data HTTP Request - * See documentation for more details + * See documentation for more details. * * @ApiDoc( * requirements={ @@ -254,7 +251,7 @@ public function deleteMediumAction($id) * } * ) * - * @param integer $id A Medium identifier + * @param int $id A Medium identifier * @param Request $request A Symfony request * * @return Media @@ -277,7 +274,7 @@ public function putMediumAction($id, Request $request) /** * Adds a medium of given provider * If you need to upload a file (depends on the provider) you will need to do so by sending content as a multipart/form-data HTTP Request - * See documentation for more details + * See documentation for more details. * * @ApiDoc( * resource=true, @@ -293,7 +290,7 @@ public function putMediumAction($id, Request $request) * @Route(requirements={"provider"="[A-Za-z0-9.]*"}) * * @param string $provider A media provider - * @param Request $request A Symfony request + * @param Request $request A Symfony request * * @return Media * @@ -313,9 +310,8 @@ public function postProviderMediumAction($provider, Request $request) return $this->handleWriteMedium($request, $medium, $mediaProvider); } - /** - * Set Binary content for a specific media + * Set Binary content for a specific media. * * @ApiDoc( * input={"class"="Sonata\MediaBundle\Model\Media", "groups"={"sonata_api_write"}}, @@ -347,9 +343,9 @@ public function putMediumBinaryContentAction($id, Request $request) } /** - * Retrieves media with id $id or throws an exception if not found + * Retrieves media with id $id or throws an exception if not found. * - * @param integer $id + * @param int $id * * @return Media * @@ -368,7 +364,7 @@ protected function getMedium($id = null) } /** - * Write a medium, this method is used by both POST and PUT action methods + * Write a medium, this method is used by both POST and PUT action methods. * * @param Request $request * @param MediaInterface $medium diff --git a/Controller/GalleryAdminController.php b/Controller/GalleryAdminController.php index 982599e07..299e7e118 100644 --- a/Controller/GalleryAdminController.php +++ b/Controller/GalleryAdminController.php @@ -19,10 +19,10 @@ class GalleryAdminController extends Controller { /** - * @param string $view - * @param array $parameters - * @param Response $response - * @param Request $request + * @param string $view + * @param array $parameters + * @param Response $response + * @param Request $request * * @return Response */ @@ -35,7 +35,7 @@ public function render($view, array $parameters = array(), Response $response = } /** - * return the Response object associated to the list action + * return the Response object associated to the list action. * * @param Request $request * diff --git a/Controller/GalleryController.php b/Controller/GalleryController.php index 9d688c2f8..268c87d86 100644 --- a/Controller/GalleryController.php +++ b/Controller/GalleryController.php @@ -22,7 +22,7 @@ class GalleryController extends Controller public function indexAction() { $galleries = $this->get('sonata.media.manager.gallery')->findBy(array( - 'enabled' => true + 'enabled' => true, )); return $this->render('SonataMediaBundle:Gallery:index.html.twig', array( @@ -34,13 +34,14 @@ public function indexAction() * @param string $id * * @return \Symfony\Bundle\FrameworkBundle\Controller\Response + * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ public function viewAction($id) { $gallery = $this->get('sonata.media.manager.gallery')->findOneBy(array( 'id' => $id, - 'enabled' => true + 'enabled' => true, )); if (!$gallery) { diff --git a/Controller/MediaAdminController.php b/Controller/MediaAdminController.php index 83d6ba65e..57c38c5d6 100644 --- a/Controller/MediaAdminController.php +++ b/Controller/MediaAdminController.php @@ -14,7 +14,6 @@ use Sonata\AdminBundle\Controller\CRUDController as Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Security\Core\Exception\AccessDeniedException; class MediaAdminController extends Controller @@ -33,7 +32,7 @@ public function createAction(Request $request = null) 'providers' => $this->get('sonata.media.pool')->getProvidersByContext($this->get('request')->get('context', $this->get('sonata.media.pool')->getDefaultContext())), 'base_template' => $this->getBaseTemplate(), 'admin' => $this->admin, - 'action' => 'create' + 'action' => 'create', )); } @@ -87,7 +86,7 @@ public function listAction(Request $request = null) if ($request->get('category')) { $contextInCategory = $this->container->get('sonata.classification.manager.category')->findBy(array( 'id' => (int) $request->get('category'), - 'context' => $context + 'context' => $context, )); if (!empty($contextInCategory)) { diff --git a/Controller/MediaController.php b/Controller/MediaController.php index 2e3d6e90f..1654f8a83 100644 --- a/Controller/MediaController.php +++ b/Controller/MediaController.php @@ -11,12 +11,12 @@ namespace Sonata\MediaBundle\Controller; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; -use Symfony\Component\HttpFoundation\BinaryFileResponse; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Provider\MediaProviderInterface; +use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Security\Core\Exception\AccessDeniedException; class MediaController extends Controller @@ -93,17 +93,17 @@ public function viewAction($id, $format = 'reference') return $this->render('SonataMediaBundle:Media:view.html.twig', array( 'media' => $media, 'formats' => $this->get('sonata.media.pool')->getFormatNamesByContext($media->getContext()), - 'format' => $format + 'format' => $format, )); } /** * This action applies a given filter to a given image, * optionally saves the image and - * outputs it to the browser at the same time + * outputs it to the browser at the same time. * - * @param string $path - * @param string $filter + * @param string $path + * @param string $filter * * @return Response */ diff --git a/DependencyInjection/Compiler/AddProviderCompilerPass.php b/DependencyInjection/Compiler/AddProviderCompilerPass.php index 2d224a720..c16a3bc5c 100644 --- a/DependencyInjection/Compiler/AddProviderCompilerPass.php +++ b/DependencyInjection/Compiler/AddProviderCompilerPass.php @@ -11,14 +11,11 @@ namespace Sonata\MediaBundle\DependencyInjection\Compiler; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** - * - * * @author Thomas Rabaix */ class AddProviderCompilerPass implements CompilerPassInterface @@ -41,7 +38,7 @@ public function process(ContainerBuilder $container) 'width' => 200, 'format' => 'jpg', 'height' => false, - 'constraint' => true + 'constraint' => true, ))); } } @@ -112,7 +109,7 @@ public function attachArguments(ContainerBuilder $container, array $settings) } /** - * Define the default settings to the config array + * Define the default settings to the config array. * * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * @param array $settings diff --git a/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php b/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php index 6b08c621f..bf2c4c7e1 100644 --- a/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php +++ b/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php @@ -1,4 +1,5 @@ */ diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 23e171c15..b5cd2322a 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1,4 +1,5 @@ @@ -41,7 +39,7 @@ public function load(array $configs, ContainerBuilder $container) $configuration = new Configuration(); $config = $processor->processConfiguration($configuration, $configs); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); + $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('provider.xml'); $loader->load('media.xml'); $loader->load('twig.xml'); @@ -165,7 +163,7 @@ public function configureBuzz(ContainerBuilder $container, array $config) foreach (array( 'sonata.media.buzz.connector.curl', - 'sonata.media.buzz.connector.file_get_contents' + 'sonata.media.buzz.connector.file_get_contents', ) as $connector) { $container->getDefinition($connector) ->addMethodCall('setIgnoreErrors', array($config['buzz']['client']['ignore_errors'])) @@ -194,8 +192,6 @@ public function configureParameterClass(ContainerBuilder $container, array $conf /** * @param array $config - * - * @return void */ public function registerDoctrineMapping(array $config) { @@ -217,11 +213,11 @@ public function registerDoctrineMapping(array $config) 'cascade' => array( 'persist', ), - 'mappedBy' => NULL, + 'mappedBy' => null, 'inversedBy' => 'galleryHasMedias', - 'joinColumns' => array( + 'joinColumns' => array( array( - 'name' => 'gallery_id', + 'name' => 'gallery_id', 'referencedColumnName' => 'id', ), ), @@ -234,11 +230,11 @@ public function registerDoctrineMapping(array $config) 'cascade' => array( 'persist', ), - 'mappedBy' => NULL, + 'mappedBy' => null, 'inversedBy' => 'galleryHasMedias', 'joinColumns' => array( array( - 'name' => 'media_id', + 'name' => 'media_id', 'referencedColumnName' => 'id', ), ), @@ -265,8 +261,8 @@ public function registerDoctrineMapping(array $config) 'cascade' => array( 'persist', ), - 'mappedBy' => NULL, - 'inversedBy' => NULL, + 'mappedBy' => null, + 'inversedBy' => null, 'joinColumns' => array( array( 'name' => 'category_id', @@ -280,12 +276,10 @@ public function registerDoctrineMapping(array $config) } /** - * Inject CDN dependency to default provider + * Inject CDN dependency to default provider. * * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * @param array $config - * - * @return void */ public function configureCdnAdapter(ContainerBuilder $container, array $config) { @@ -331,12 +325,10 @@ public function configureCdnAdapter(ContainerBuilder $container, array $config) } /** - * Inject filesystem dependency to default provider + * Inject filesystem dependency to default provider. * * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * @param array $config - * - * @return void */ public function configureFilesystemAdapter(ContainerBuilder $container, array $config) { @@ -356,12 +348,12 @@ public function configureFilesystemAdapter(ContainerBuilder $container, array $c ->addArgument($config['filesystem']['ftp']['directory']) ->addArgument($config['filesystem']['ftp']['host']) ->addArgument(array( - 'port' => $config['filesystem']['ftp']['port'], + 'port' => $config['filesystem']['ftp']['port'], 'username' => $config['filesystem']['ftp']['username'], 'password' => $config['filesystem']['ftp']['password'], - 'passive' => $config['filesystem']['ftp']['passive'], - 'create' => $config['filesystem']['ftp']['create'], - 'mode' => $config['filesystem']['ftp']['mode'] + 'passive' => $config['filesystem']['ftp']['passive'], + 'create' => $config['filesystem']['ftp']['create'], + 'mode' => $config['filesystem']['ftp']['mode'], )) ; } else { @@ -379,11 +371,11 @@ public function configureFilesystemAdapter(ContainerBuilder $container, array $c $container->getDefinition('sonata.media.metadata.amazon') ->addArgument(array( - 'acl' => $config['filesystem']['s3']['acl'], - 'storage' => $config['filesystem']['s3']['storage'], - 'encryption' => $config['filesystem']['s3']['encryption'], - 'meta' => $config['filesystem']['s3']['meta'], - 'cache_control' => $config['filesystem']['s3']['cache_control'] + 'acl' => $config['filesystem']['s3']['acl'], + 'storage' => $config['filesystem']['s3']['storage'], + 'encryption' => $config['filesystem']['s3']['encryption'], + 'meta' => $config['filesystem']['s3']['meta'], + 'cache_control' => $config['filesystem']['s3']['cache_control'], )) ; @@ -461,61 +453,61 @@ public function configureExtra(ContainerBuilder $container, array $config) } /** - * Add class to compile + * Add class to compile. */ public function configureClassesToCompile() { $this->addClassesToCompile(array( - "Sonata\\MediaBundle\\CDN\\CDNInterface", - "Sonata\\MediaBundle\\CDN\\CloudFront", - "Sonata\\MediaBundle\\CDN\\Fallback", - "Sonata\\MediaBundle\\CDN\\PantherPortal", - "Sonata\\MediaBundle\\CDN\\Server", - "Sonata\\MediaBundle\\Extra\\Pixlr", - "Sonata\\MediaBundle\\Filesystem\\Local", - "Sonata\\MediaBundle\\Filesystem\\Replicate", - "Sonata\\MediaBundle\\Generator\\DefaultGenerator", - "Sonata\\MediaBundle\\Generator\\GeneratorInterface", - "Sonata\\MediaBundle\\Generator\\ODMGenerator", - "Sonata\\MediaBundle\\Generator\\PHPCRGenerator", - "Sonata\\MediaBundle\\Metadata\\AmazonMetadataBuilder", - "Sonata\\MediaBundle\\Metadata\\MetadataBuilderInterface", - "Sonata\\MediaBundle\\Metadata\\NoopMetadataBuilder", - "Sonata\\MediaBundle\\Metadata\\ProxyMetadataBuilder", - "Sonata\\MediaBundle\\Model\\Gallery", - "Sonata\\MediaBundle\\Model\\GalleryHasMedia", - "Sonata\\MediaBundle\\Model\\GalleryHasMediaInterface", - "Sonata\\MediaBundle\\Model\\GalleryInterface", - "Sonata\\MediaBundle\\Model\\GalleryManager", - "Sonata\\MediaBundle\\Model\\GalleryManagerInterface", - "Sonata\\MediaBundle\\Model\\Media", - "Sonata\\MediaBundle\\Model\\MediaInterface", - "Sonata\\MediaBundle\\Model\\MediaManagerInterface", - "Sonata\\MediaBundle\\Provider\\BaseProvider", - "Sonata\\MediaBundle\\Provider\\BaseVideoProvider", - "Sonata\\MediaBundle\\Provider\\DailyMotionProvider", - "Sonata\\MediaBundle\\Provider\\FileProvider", - "Sonata\\MediaBundle\\Provider\\ImageProvider", - "Sonata\\MediaBundle\\Provider\\MediaProviderInterface", - "Sonata\\MediaBundle\\Provider\\Pool", - "Sonata\\MediaBundle\\Provider\\VimeoProvider", - "Sonata\\MediaBundle\\Provider\\YouTubeProvider", - "Sonata\\MediaBundle\\Resizer\\ResizerInterface", - "Sonata\\MediaBundle\\Resizer\\SimpleResizer", - "Sonata\\MediaBundle\\Resizer\\SquareResizer", - "Sonata\\MediaBundle\\Security\\DownloadStrategyInterface", - "Sonata\\MediaBundle\\Security\\ForbiddenDownloadStrategy", - "Sonata\\MediaBundle\\Security\\PublicDownloadStrategy", - "Sonata\\MediaBundle\\Security\\RolesDownloadStrategy", - "Sonata\\MediaBundle\\Security\\SessionDownloadStrategy", - "Sonata\\MediaBundle\\Templating\\Helper\\MediaHelper", - "Sonata\\MediaBundle\\Thumbnail\\ConsumerThumbnail", - "Sonata\\MediaBundle\\Thumbnail\\FormatThumbnail", - "Sonata\\MediaBundle\\Thumbnail\\ThumbnailInterface", - "Sonata\\MediaBundle\\Twig\\Extension\\MediaExtension", - "Sonata\\MediaBundle\\Twig\\Node\\MediaNode", - "Sonata\\MediaBundle\\Twig\\Node\\PathNode", - "Sonata\\MediaBundle\\Twig\\Node\\ThumbnailNode", + 'Sonata\\MediaBundle\\CDN\\CDNInterface', + 'Sonata\\MediaBundle\\CDN\\CloudFront', + 'Sonata\\MediaBundle\\CDN\\Fallback', + 'Sonata\\MediaBundle\\CDN\\PantherPortal', + 'Sonata\\MediaBundle\\CDN\\Server', + 'Sonata\\MediaBundle\\Extra\\Pixlr', + 'Sonata\\MediaBundle\\Filesystem\\Local', + 'Sonata\\MediaBundle\\Filesystem\\Replicate', + 'Sonata\\MediaBundle\\Generator\\DefaultGenerator', + 'Sonata\\MediaBundle\\Generator\\GeneratorInterface', + 'Sonata\\MediaBundle\\Generator\\ODMGenerator', + 'Sonata\\MediaBundle\\Generator\\PHPCRGenerator', + 'Sonata\\MediaBundle\\Metadata\\AmazonMetadataBuilder', + 'Sonata\\MediaBundle\\Metadata\\MetadataBuilderInterface', + 'Sonata\\MediaBundle\\Metadata\\NoopMetadataBuilder', + 'Sonata\\MediaBundle\\Metadata\\ProxyMetadataBuilder', + 'Sonata\\MediaBundle\\Model\\Gallery', + 'Sonata\\MediaBundle\\Model\\GalleryHasMedia', + 'Sonata\\MediaBundle\\Model\\GalleryHasMediaInterface', + 'Sonata\\MediaBundle\\Model\\GalleryInterface', + 'Sonata\\MediaBundle\\Model\\GalleryManager', + 'Sonata\\MediaBundle\\Model\\GalleryManagerInterface', + 'Sonata\\MediaBundle\\Model\\Media', + 'Sonata\\MediaBundle\\Model\\MediaInterface', + 'Sonata\\MediaBundle\\Model\\MediaManagerInterface', + 'Sonata\\MediaBundle\\Provider\\BaseProvider', + 'Sonata\\MediaBundle\\Provider\\BaseVideoProvider', + 'Sonata\\MediaBundle\\Provider\\DailyMotionProvider', + 'Sonata\\MediaBundle\\Provider\\FileProvider', + 'Sonata\\MediaBundle\\Provider\\ImageProvider', + 'Sonata\\MediaBundle\\Provider\\MediaProviderInterface', + 'Sonata\\MediaBundle\\Provider\\Pool', + 'Sonata\\MediaBundle\\Provider\\VimeoProvider', + 'Sonata\\MediaBundle\\Provider\\YouTubeProvider', + 'Sonata\\MediaBundle\\Resizer\\ResizerInterface', + 'Sonata\\MediaBundle\\Resizer\\SimpleResizer', + 'Sonata\\MediaBundle\\Resizer\\SquareResizer', + 'Sonata\\MediaBundle\\Security\\DownloadStrategyInterface', + 'Sonata\\MediaBundle\\Security\\ForbiddenDownloadStrategy', + 'Sonata\\MediaBundle\\Security\\PublicDownloadStrategy', + 'Sonata\\MediaBundle\\Security\\RolesDownloadStrategy', + 'Sonata\\MediaBundle\\Security\\SessionDownloadStrategy', + 'Sonata\\MediaBundle\\Templating\\Helper\\MediaHelper', + 'Sonata\\MediaBundle\\Thumbnail\\ConsumerThumbnail', + 'Sonata\\MediaBundle\\Thumbnail\\FormatThumbnail', + 'Sonata\\MediaBundle\\Thumbnail\\ThumbnailInterface', + 'Sonata\\MediaBundle\\Twig\\Extension\\MediaExtension', + 'Sonata\\MediaBundle\\Twig\\Node\\MediaNode', + 'Sonata\\MediaBundle\\Twig\\Node\\PathNode', + 'Sonata\\MediaBundle\\Twig\\Node\\ThumbnailNode', )); } } diff --git a/Document/BaseGallery.php b/Document/BaseGallery.php index 28fff462a..88582aeff 100644 --- a/Document/BaseGallery.php +++ b/Document/BaseGallery.php @@ -14,21 +14,20 @@ use Sonata\MediaBundle\Model\Gallery; /** - * Bundle\MediaBundle\Document\BaseGallery + * Bundle\MediaBundle\Document\BaseGallery. */ abstract class BaseGallery extends Gallery { - /** * {@inheritdoc} */ public function __construct() { - $this->galleryHasMedias = new \Doctrine\Common\Collections\ArrayCollection; + $this->galleryHasMedias = new \Doctrine\Common\Collections\ArrayCollection(); } /** - * Pre Persist method + * Pre Persist method. */ public function prePersist() { @@ -37,7 +36,7 @@ public function prePersist() } /** - * Pre Update method + * Pre Update method. */ public function preUpdate() { diff --git a/Document/BaseGalleryHasMedia.php b/Document/BaseGalleryHasMedia.php index b92c34052..36ccbdc43 100644 --- a/Document/BaseGalleryHasMedia.php +++ b/Document/BaseGalleryHasMedia.php @@ -1,4 +1,5 @@ galleryHasMedias = new \Doctrine\Common\Collections\ArrayCollection; + $this->galleryHasMedias = new \Doctrine\Common\Collections\ArrayCollection(); } /** - * Pre Persist method + * Pre Persist method. */ public function prePersist() { @@ -36,7 +36,7 @@ public function prePersist() } /** - * Pre Update method + * Pre Update method. */ public function preUpdate() { diff --git a/Entity/BaseGalleryHasMedia.php b/Entity/BaseGalleryHasMedia.php index a523f8876..f522b6929 100644 --- a/Entity/BaseGalleryHasMedia.php +++ b/Entity/BaseGalleryHasMedia.php @@ -1,4 +1,5 @@ getId() . $media->getCreatedAt()->format('u') . $this->secret); + return sha1($media->getId().$media->getCreatedAt()->format('u').$this->secret); } /** @@ -98,8 +98,6 @@ private function getMedia($id) * * @param string $hash * @param \Sonata\MediaBundle\Model\MediaInterface $media - * - * @return void */ private function checkMedia($hash, MediaInterface $media) { @@ -193,7 +191,7 @@ public function targetAction(Request $request, $hash, $id) $provider = $this->pool->getProvider($media->getProviderName()); - /** + /* * Pixlr send back the new image as an url, add some security check before downloading the file */ if (!preg_match($this->allowEreg, $request->get('image'), $matches)) { diff --git a/Filesystem/Local.php b/Filesystem/Local.php index 0da30e2f4..2394a50df 100644 --- a/Filesystem/Local.php +++ b/Filesystem/Local.php @@ -1,4 +1,5 @@ slave->delete($key); } catch (\Exception $e) { - if ($this->logger) { - $this->logger->critical(sprintf("Unable to delete %s, error: %s", $key, $e->getMessage())); + $this->logger->critical(sprintf('Unable to delete %s, error: %s', $key, $e->getMessage())); } $ok = false; @@ -55,9 +55,8 @@ public function delete($key) try { $this->master->delete($key); } catch (\Exception $e) { - if ($this->logger) { - $this->logger->critical(sprintf("Unable to delete %s, error: %s", $key, $e->getMessage())); + $this->logger->critical(sprintf('Unable to delete %s, error: %s', $key, $e->getMessage())); } $ok = false; @@ -101,9 +100,8 @@ public function write($key, $content, array $metadata = null) try { $return = $this->master->write($key, $content, $metadata); } catch (\Exception $e) { - if ($this->logger) { - $this->logger->critical(sprintf("Unable to write %s, error: %s", $key, $e->getMessage())); + $this->logger->critical(sprintf('Unable to write %s, error: %s', $key, $e->getMessage())); } $ok = false; @@ -112,9 +110,8 @@ public function write($key, $content, array $metadata = null) try { $return = $this->slave->write($key, $content, $metadata); } catch (\Exception $e) { - if ($this->logger) { - $this->logger->critical(sprintf("Unable to write %s, error: %s", $key, $e->getMessage())); + $this->logger->critical(sprintf('Unable to write %s, error: %s', $key, $e->getMessage())); } $ok = false; @@ -141,9 +138,8 @@ public function rename($key, $new) try { $this->master->rename($key, $new); } catch (\Exception $e) { - if ($this->logger) { - $this->logger->critical(sprintf("Unable to rename %s, error: %s", $key, $e->getMessage())); + $this->logger->critical(sprintf('Unable to rename %s, error: %s', $key, $e->getMessage())); } $ok = false; @@ -152,9 +148,8 @@ public function rename($key, $new) try { $this->slave->rename($key, $new); } catch (\Exception $e) { - if ($this->logger) { - $this->logger->critical(sprintf("Unable to rename %s, error: %s", $key, $e->getMessage())); + $this->logger->critical(sprintf('Unable to rename %s, error: %s', $key, $e->getMessage())); } $ok = false; @@ -164,7 +159,7 @@ public function rename($key, $new) } /** - * If one of the adapters can allow inserting metadata + * If one of the adapters can allow inserting metadata. * * @return bool true if supports metadata, false if not */ @@ -201,10 +196,9 @@ public function getMetadata($key) } /** - * Gets the class names as an array for both adapters + * Gets the class names as an array for both adapters. * * @return array - * */ public function getAdapterClassNames() { diff --git a/Form/DataTransformer/ProviderDataTransformer.php b/Form/DataTransformer/ProviderDataTransformer.php index 8eb0b6a7f..814462f88 100644 --- a/Form/DataTransformer/ProviderDataTransformer.php +++ b/Form/DataTransformer/ProviderDataTransformer.php @@ -11,9 +11,9 @@ namespace Sonata\MediaBundle\Form\DataTransformer; -use Symfony\Component\Form\DataTransformerInterface; -use Sonata\MediaBundle\Provider\Pool; use Sonata\MediaBundle\Model\MediaInterface; +use Sonata\MediaBundle\Provider\Pool; +use Symfony\Component\Form\DataTransformerInterface; class ProviderDataTransformer implements DataTransformerInterface { @@ -31,18 +31,17 @@ public function __construct(Pool $pool, $class, array $options = array()) $this->pool = $pool; $this->options = $this->getOptions($options); $this->class = $class; - } /** - * Define the default options for the DataTransformer + * Define the default options for the DataTransformer. * * @param array $options + * * @return array */ protected function getOptions(array $options) { - return array_merge(array( 'provider' => false, 'context' => false, @@ -57,7 +56,7 @@ protected function getOptions(array $options) public function transform($value) { if ($value === null) { - return new $this->class; + return new $this->class(); } return $value; @@ -75,10 +74,10 @@ public function reverseTransform($media) $binaryContent = $media->getBinaryContent(); // no binary - if (empty($binaryContent)){ + if (empty($binaryContent)) { // and no media id if ($media->getId() === null && $this->options['empty_on_new']) { - return null; + return; } elseif ($media->getId()) { return $media; } @@ -90,7 +89,7 @@ public function reverseTransform($media) } // create a new media to avoid erasing other media or not ... - $newMedia = $this->options['new_on_update'] ? new $this->class : $media; + $newMedia = $this->options['new_on_update'] ? new $this->class() : $media; $newMedia->setProviderName($media->getProviderName()); $newMedia->setContext($media->getContext()); diff --git a/Form/DataTransformer/ServiceProviderDataTransformer.php b/Form/DataTransformer/ServiceProviderDataTransformer.php index 5f5201358..269a90344 100644 --- a/Form/DataTransformer/ServiceProviderDataTransformer.php +++ b/Form/DataTransformer/ServiceProviderDataTransformer.php @@ -11,9 +11,9 @@ namespace Sonata\MediaBundle\Form\DataTransformer; -use Symfony\Component\Form\DataTransformerInterface; use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Provider\MediaProviderInterface; +use Symfony\Component\Form\DataTransformerInterface; class ServiceProviderDataTransformer implements DataTransformerInterface { diff --git a/Form/Type/ApiMediaType.php b/Form/Type/ApiMediaType.php index a1c4717fd..83115e3f0 100644 --- a/Form/Type/ApiMediaType.php +++ b/Form/Type/ApiMediaType.php @@ -1,4 +1,5 @@ */ class ApiMediaType extends AbstractType { /** - * @var Pool $mediaPool + * @var Pool */ protected $mediaPool; /** - * @var string $class + * @var string */ protected $class; @@ -54,7 +52,7 @@ public function __construct(Pool $mediaPool, $class) public function buildForm(FormBuilderInterface $builder, array $options) { $builder->addModelTransformer(new ProviderDataTransformer($this->mediaPool, $this->class, array( - 'empty_on_new' => false + 'empty_on_new' => false, )), true); $provider = $this->mediaPool->getProvider($options['provider_name']); @@ -77,8 +75,8 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'provider_name' => "sonata.media.provider.image", - 'context' => 'api' + 'provider_name' => 'sonata.media.provider.image', + 'context' => 'api', )); } @@ -87,7 +85,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return "sonata_media_api_form_doctrine_media"; + return 'sonata_media_api_form_doctrine_media'; } /** @@ -95,8 +93,6 @@ public function getParent() */ public function getName() { - return "sonata_media_api_form_media"; + return 'sonata_media_api_form_media'; } - - } diff --git a/Form/Type/MediaType.php b/Form/Type/MediaType.php index bc570e124..f32890e11 100644 --- a/Form/Type/MediaType.php +++ b/Form/Type/MediaType.php @@ -11,9 +11,10 @@ namespace Sonata\MediaBundle\Form\Type; +use Sonata\MediaBundle\Form\DataTransformer\ProviderDataTransformer; +use Sonata\MediaBundle\Provider\Pool; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; - use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormInterface; @@ -21,9 +22,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolverInterface; -use Sonata\MediaBundle\Provider\Pool; -use Sonata\MediaBundle\Form\DataTransformer\ProviderDataTransformer; - class MediaType extends AbstractType { protected $pool; @@ -52,7 +50,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'new_on_update' => $options['new_on_update'], ))); - $builder->addEventListener(FormEvents::BIND, function(FormEvent $event) { + $builder->addEventListener(FormEvents::BIND, function (FormEvent $event) { if ($event->getForm()->has('unlink') && $event->getForm()->get('unlink')->getData()) { $event->setData(null); } @@ -63,7 +61,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->add('unlink', 'checkbox', array( 'mapped' => false, 'data' => false, - 'required' => false + 'required' => false, )); } diff --git a/Generator/DefaultGenerator.php b/Generator/DefaultGenerator.php index 459cb1c08..b186f011a 100644 --- a/Generator/DefaultGenerator.php +++ b/Generator/DefaultGenerator.php @@ -1,4 +1,5 @@ 1) { // remove last part from id array_pop($segments); - $path = join($segments, '/'); + $path = implode($segments, '/'); } else { $path = ''; } diff --git a/Listener/BaseMediaEventSubscriber.php b/Listener/BaseMediaEventSubscriber.php index ed2d7ebe2..f3cb72191 100644 --- a/Listener/BaseMediaEventSubscriber.php +++ b/Listener/BaseMediaEventSubscriber.php @@ -11,9 +11,8 @@ namespace Sonata\MediaBundle\Listener; -use Doctrine\Common\EventSubscriber; use Doctrine\Common\EventArgs; - +use Doctrine\Common\EventSubscriber; use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Provider\Pool; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -42,12 +41,10 @@ public function getPool() * @abstract * * @param \Doctrine\Common\EventArgs $args - * - * @return void */ abstract protected function recomputeSingleEntityChangeSet(EventArgs $args); - /** + /** * @abstract * * @param \Doctrine\Common\EventArgs $args @@ -66,7 +63,7 @@ protected function getProvider(EventArgs $args) $media = $this->getMedia($args); if (!$media instanceof MediaInterface) { - return null; + return; } return $this->getPool()->getProvider($media->getProviderName()); @@ -74,8 +71,6 @@ protected function getProvider(EventArgs $args) /** * @param \Doctrine\Common\EventArgs $args - * - * @return void */ public function postUpdate(EventArgs $args) { @@ -88,8 +83,6 @@ public function postUpdate(EventArgs $args) /** * @param \Doctrine\Common\EventArgs $args - * - * @return void */ public function postRemove(EventArgs $args) { @@ -102,8 +95,6 @@ public function postRemove(EventArgs $args) /** * @param \Doctrine\Common\EventArgs $args - * - * @return void */ public function postPersist(EventArgs $args) { @@ -116,8 +107,6 @@ public function postPersist(EventArgs $args) /** * @param \Doctrine\Common\EventArgs $args - * - * @return void */ public function preUpdate(EventArgs $args) { @@ -133,8 +122,6 @@ public function preUpdate(EventArgs $args) /** * @param \Doctrine\Common\EventArgs $args - * - * @return void */ public function preRemove(EventArgs $args) { @@ -147,8 +134,6 @@ public function preRemove(EventArgs $args) /** * @param \Doctrine\Common\EventArgs $args - * - * @return void */ public function prePersist(EventArgs $args) { diff --git a/Listener/ODM/MediaEventSubscriber.php b/Listener/ODM/MediaEventSubscriber.php index 2f379a1a3..d5e91c5ce 100644 --- a/Listener/ODM/MediaEventSubscriber.php +++ b/Listener/ODM/MediaEventSubscriber.php @@ -33,8 +33,7 @@ public function getSubscribedEvents() } /** - * @param \Doctrine\Common\EventArgs $args - * @return void + * @param \Doctrine\Common\EventArgs $args */ protected function recomputeSingleEntityChangeSet(EventArgs $args) { diff --git a/Listener/ORM/MediaEventSubscriber.php b/Listener/ORM/MediaEventSubscriber.php index 334dec188..0cd211c43 100644 --- a/Listener/ORM/MediaEventSubscriber.php +++ b/Listener/ORM/MediaEventSubscriber.php @@ -36,8 +36,7 @@ public function getSubscribedEvents() } /** - * @param \Doctrine\Common\EventArgs $args - * @return void + * @param \Doctrine\Common\EventArgs $args */ protected function recomputeSingleEntityChangeSet(EventArgs $args) { diff --git a/Listener/PHPCR/MediaEventSubscriber.php b/Listener/PHPCR/MediaEventSubscriber.php index 2e7fb86ae..02460404d 100644 --- a/Listener/PHPCR/MediaEventSubscriber.php +++ b/Listener/PHPCR/MediaEventSubscriber.php @@ -37,7 +37,7 @@ public function getSubscribedEvents() */ protected function recomputeSingleEntityChangeSet(EventArgs $args) { - /** @var $args \Doctrine\Common\Persistence\Event\LifecycleEventArgs */ + /* @var $args \Doctrine\Common\Persistence\Event\LifecycleEventArgs */ /** @var $dm \Doctrine\ODM\PHPCR\DocumentManager */ $dm = $args->getObjectManager(); diff --git a/Makefile b/Makefile index bd699a88f..8b21c165a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,12 @@ +cs: + ./vendor/bin/php-cs-fixer fix --verbose + +cs_dry_run: + ./vendor/bin/php-cs-fixer fix --verbose --dry-run + test: phpunit cd Resources/doc && sphinx-build -W -b html -d _build/doctrees . _build/html bower: - /usr/local/node/node-v0.10.22/bin/bower update \ No newline at end of file + /usr/local/node/node-v0.10.22/bin/bower update diff --git a/Metadata/AmazonMetadataBuilder.php b/Metadata/AmazonMetadataBuilder.php index 6011c5ef4..06a046bd2 100644 --- a/Metadata/AmazonMetadataBuilder.php +++ b/Metadata/AmazonMetadataBuilder.php @@ -11,16 +11,13 @@ namespace Sonata\MediaBundle\Metadata; -use Sonata\MediaBundle\Metadata\MetadataBuilderInterface; -use Sonata\MediaBundle\Model\MediaInterface; - use Aws\S3\Enum\CannedAcl; use Aws\S3\Enum\Storage; use Guzzle\Http\Mimetypes; +use Sonata\MediaBundle\Model\MediaInterface; class AmazonMetadataBuilder implements MetadataBuilderInterface { - protected $settings; protected $acl = array( @@ -41,7 +38,7 @@ public function __construct(array $settings) } /** - * Get data passed from the config + * Get data passed from the config. * * @return array */ @@ -83,7 +80,7 @@ protected function getDefaultMetadata() } /** - * Gets the correct content-type + * Gets the correct content-type. * * @param string $filename * @@ -94,7 +91,7 @@ protected function getContentType($filename) $extension = pathinfo($filename, PATHINFO_EXTENSION); $contentType = Mimetypes::getInstance()->fromExtension($extension); - return array('contentType'=> $contentType); + return array('contentType' => $contentType); } /** diff --git a/Metadata/MetadataBuilderInterface.php b/Metadata/MetadataBuilderInterface.php index 3560fb031..8be1b8989 100644 --- a/Metadata/MetadataBuilderInterface.php +++ b/Metadata/MetadataBuilderInterface.php @@ -15,9 +15,8 @@ interface MetadataBuilderInterface { - /** - * Get metadata for media object + * Get metadata for media object. * * @param MediaInterface $media * @param string $filename diff --git a/Metadata/NoopMetadataBuilder.php b/Metadata/NoopMetadataBuilder.php index da10daa9a..10653c50d 100644 --- a/Metadata/NoopMetadataBuilder.php +++ b/Metadata/NoopMetadataBuilder.php @@ -11,7 +11,6 @@ namespace Sonata\MediaBundle\Metadata; -use Sonata\MediaBundle\Metadata\MetadataBuilderInterface; use Sonata\MediaBundle\Model\MediaInterface; class NoopMetadataBuilder implements MetadataBuilderInterface diff --git a/Metadata/ProxyMetadataBuilder.php b/Metadata/ProxyMetadataBuilder.php index ef694ab02..ab6889032 100644 --- a/Metadata/ProxyMetadataBuilder.php +++ b/Metadata/ProxyMetadataBuilder.php @@ -11,9 +11,8 @@ namespace Sonata\MediaBundle\Metadata; -use Sonata\MediaBundle\Metadata\MetadataBuilderInterface; -use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Filesystem\Replicate; +use Sonata\MediaBundle\Model\MediaInterface; use Symfony\Component\DependencyInjection\ContainerInterface; class ProxyMetadataBuilder implements MetadataBuilderInterface @@ -33,8 +32,8 @@ public function __construct(ContainerInterface $container, array $map) } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function get(MediaInterface $media, $filename) { //get adapter for current media diff --git a/Model/Gallery.php b/Model/Gallery.php index d0a46f764..1e9fcd573 100644 --- a/Model/Gallery.php +++ b/Model/Gallery.php @@ -1,4 +1,5 @@ getClass(); - return new $class; + return new $class(); } } diff --git a/Model/Media.php b/Model/Media.php index 767e21d13..72ba96b0f 100644 --- a/Model/Media.php +++ b/Model/Media.php @@ -1,4 +1,5 @@ setCreatedAt(new \DateTime); - $this->setUpdatedAt(new \DateTime); + $this->setCreatedAt(new \DateTime()); + $this->setUpdatedAt(new \DateTime()); } public function preUpdate() { - $this->setUpdatedAt(new \DateTime); + $this->setUpdatedAt(new \DateTime()); } /** * @static + * * @return array */ public static function getStatusList() diff --git a/Model/MediaInterface.php b/Model/MediaInterface.php index 7487981d6..75ca2c426 100644 --- a/Model/MediaInterface.php +++ b/Model/MediaInterface.php @@ -19,7 +19,7 @@ interface MediaInterface const STATUS_ERROR = 4; const STATUS_ENCODING = 5; - const MISSING_BINARY_REFERENCE = "missing_binary_content"; + const MISSING_BINARY_REFERENCE = 'missing_binary_content'; /** * @param mixed $binaryContent @@ -32,7 +32,7 @@ public function setBinaryContent($binaryContent); public function getBinaryContent(); /** - * Reset the binary content + * Reset the binary content. */ public function resetBinaryContent(); @@ -49,7 +49,7 @@ public function getMetadataValue($name, $default = null); public function setMetadataValue($name, $value); /** - * Remove a named data from the metadata + * Remove a named data from the metadata. * * @param string $name */ @@ -61,259 +61,259 @@ public function unsetMetadataValue($name); public function getId(); /** - * Set name + * Set name. * * @param string $name */ public function setName($name); /** - * Get name + * Get name. * * @return string $name */ public function getName(); /** - * Set description + * Set description. * * @param string $description */ public function setDescription($description); /** - * Get description + * Get description. * * @return string $description */ public function getDescription(); /** - * Set enabled + * Set enabled. * - * @param boolean $enabled + * @param bool $enabled */ public function setEnabled($enabled); /** - * Get enabled + * Get enabled. * - * @return boolean $enabled + * @return bool $enabled */ public function getEnabled(); /** - * Set provider_name + * Set provider_name. * * @param string $providerName */ public function setProviderName($providerName); /** - * Get provider_name + * Get provider_name. * * @return string $providerName */ public function getProviderName(); /** - * Set provider_status + * Set provider_status. * - * @param integer $providerStatus + * @param int $providerStatus */ public function setProviderStatus($providerStatus); /** - * Get provider_status + * Get provider_status. * - * @return integer $providerStatus + * @return int $providerStatus */ public function getProviderStatus(); /** - * Set provider_reference + * Set provider_reference. * * @param string $providerReference */ public function setProviderReference($providerReference); /** - * Get provider_reference + * Get provider_reference. * * @return string $providerReference */ public function getProviderReference(); /** - * Set provider_metadata + * Set provider_metadata. * * @param array $providerMetadata */ public function setProviderMetadata(array $providerMetadata = array()); /** - * Get provider_metadata + * Get provider_metadata. * * @return array $providerMetadata */ public function getProviderMetadata(); /** - * Set width + * Set width. * - * @param integer $width + * @param int $width */ public function setWidth($width); /** - * Get width + * Get width. * - * @return integer $width + * @return int $width */ public function getWidth(); /** - * Set height + * Set height. * - * @param integer $height + * @param int $height */ public function setHeight($height); /** - * Get height + * Get height. * - * @return integer $height + * @return int $height */ public function getHeight(); /** - * Set length + * Set length. * * @param float $length */ public function setLength($length); /** - * Get length + * Get length. * * @return float $length */ public function getLength(); /** - * Set copyright + * Set copyright. * * @param string $copyright */ public function setCopyright($copyright); /** - * Get copyright + * Get copyright. * * @return string $copyright */ public function getCopyright(); /** - * Set authorName + * Set authorName. * * @param string $authorName */ public function setAuthorName($authorName); /** - * Get authorName + * Get authorName. * * @return string $authorName */ public function getAuthorName(); /** - * Set context + * Set context. * * @param string $context */ public function setContext($context); /** - * Get context + * Get context. * * @return string $context */ public function getContext(); /** - * Set cdnIsFlushable + * Set cdnIsFlushable. * - * @param boolean $cdnIsFlushable + * @param bool $cdnIsFlushable */ public function setCdnIsFlushable($cdnIsFlushable); /** - * Get cdn_is_flushable + * Get cdn_is_flushable. * - * @return boolean $cdnIsFlushable + * @return bool $cdnIsFlushable */ public function getCdnIsFlushable(); /** - * Set cdn_flush_identifier + * Set cdn_flush_identifier. * - * @param boolean $cdnFlushIdentifier + * @param bool $cdnFlushIdentifier */ public function setCdnFlushIdentifier($cdnFlushIdentifier); /** - * Get cdn_flush_identifier + * Get cdn_flush_identifier. * * @return string $cdnFlushIdentifier */ public function getCdnFlushIdentifier(); /** - * Set cdn_flush_at + * Set cdn_flush_at. * * @param \Datetime $cdnFlushAt */ public function setCdnFlushAt(\Datetime $cdnFlushAt = null); /** - * Get cdn_flush_at + * Get cdn_flush_at. * * @return \Datetime $cdnFlushAt */ public function getCdnFlushAt(); /** - * Set updated_at + * Set updated_at. * * @param \Datetime $updatedAt */ public function setUpdatedAt(\Datetime $updatedAt = null); /** - * Get updated_at + * Get updated_at. * * @return \Datetime $updatedAt */ public function getUpdatedAt(); /** - * Set created_at + * Set created_at. * * @param \Datetime $createdAt */ public function setCreatedAt(\Datetime $createdAt = null); /** - * Get created_at + * Get created_at. * * @return \Datetime $createdAt */ public function getCreatedAt(); /** - * Set content_type + * Set content_type. * * @param string $contentType */ @@ -325,38 +325,37 @@ public function setContentType($contentType); public function getExtension(); /** - * Get content_type + * Get content_type. * * @return string $contentType */ public function getContentType(); /** - * Set size + * Set size. * - * @param integer $size + * @param int $size */ public function setSize($size); /** - * Get size + * Get size. * - * @return integer $size + * @return int $size */ public function getSize(); /** - * Set cdn_status + * Set cdn_status. * - * @param integer $cdnStatus + * @param int $cdnStatus */ public function setCdnStatus($cdnStatus); /** + * Get cdn_status. * - * Get cdn_status - * - * @return integer $cdnStatus + * @return int $cdnStatus */ public function getCdnStatus(); @@ -367,8 +366,6 @@ public function getBox(); /** * @param array $galleryHasMedias - * - * @return void */ public function setGalleryHasMedias($galleryHasMedias); diff --git a/Model/MediaManagerInterface.php b/Model/MediaManagerInterface.php index f2642779f..9d45a66ea 100644 --- a/Model/MediaManagerInterface.php +++ b/Model/MediaManagerInterface.php @@ -19,5 +19,4 @@ */ interface MediaManagerInterface extends ManagerInterface, PageableManagerInterface { - } diff --git a/PHPCR/BaseGallery.php b/PHPCR/BaseGallery.php index a9b3c3732..f2e122ae5 100644 --- a/PHPCR/BaseGallery.php +++ b/PHPCR/BaseGallery.php @@ -15,7 +15,7 @@ use Sonata\MediaBundle\Model\GalleryHasMediaInterface; /** - * Bundle\MediaBundle\Document\BaseGallery + * Bundle\MediaBundle\Document\BaseGallery. */ abstract class BaseGallery extends Gallery { @@ -29,11 +29,11 @@ abstract class BaseGallery extends Gallery */ public function __construct() { - $this->galleryHasMedias = new \Doctrine\Common\Collections\ArrayCollection; + $this->galleryHasMedias = new \Doctrine\Common\Collections\ArrayCollection(); } /** - * Get universal unique id + * Get universal unique id. * * @return string */ @@ -60,7 +60,7 @@ public function addGalleryHasMedias(GalleryHasMediaInterface $galleryHasMedia) } /** - * Pre persist method + * Pre persist method. */ public function prePersist() { @@ -71,7 +71,7 @@ public function prePersist() } /** - * Pre Update method + * Pre Update method. */ public function preUpdate() { @@ -81,7 +81,7 @@ public function preUpdate() } /** - * Reorders $galleryHasMedia items based on their position + * Reorders $galleryHasMedia items based on their position. */ public function reorderGalleryHasMedia() { diff --git a/PHPCR/BaseGalleryHasMedia.php b/PHPCR/BaseGalleryHasMedia.php index 95a013c3a..4bb6d7961 100644 --- a/PHPCR/BaseGalleryHasMedia.php +++ b/PHPCR/BaseGalleryHasMedia.php @@ -1,4 +1,5 @@ getName(), $this->getName().".description", false, "SonataMediaBundle", array('class' => 'fa fa-file')); + return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', array('class' => 'fa fa-file')); } /** @@ -186,7 +184,6 @@ public function preRemove(MediaInterface $media) */ public function postRemove(MediaInterface $media) { - } /** @@ -230,7 +227,6 @@ public function setTemplates(array $templates) } /** - * * @return array */ public function getTemplates() @@ -308,6 +304,5 @@ public function preUpdate(MediaInterface $media) */ public function validate(ErrorElement $errorElement, MediaInterface $media) { - } } diff --git a/Provider/BaseVideoProvider.php b/Provider/BaseVideoProvider.php index 4e4d69670..2e5d1f528 100644 --- a/Provider/BaseVideoProvider.php +++ b/Provider/BaseVideoProvider.php @@ -11,16 +11,16 @@ namespace Sonata\MediaBundle\Provider; +use Buzz\Browser; use Gaufrette\Filesystem; use Sonata\AdminBundle\Form\FormMapper; use Sonata\CoreBundle\Model\Metadata; -use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\CDN\CDNInterface; use Sonata\MediaBundle\Generator\GeneratorInterface; -use Buzz\Browser; +use Sonata\MediaBundle\Metadata\MetadataBuilderInterface; +use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Thumbnail\ThumbnailInterface; use Symfony\Component\Form\FormBuilder; -use Sonata\MediaBundle\Metadata\MetadataBuilderInterface; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotNull; @@ -50,7 +50,7 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().".description", null, "SonataMediaBundle", array('class' => 'fa fa-video-camera')); + return new Metadata($this->getName(), $this->getName().'.description', null, 'SonataMediaBundle', array('class' => 'fa fa-video-camera')); } /** @@ -126,8 +126,8 @@ public function buildCreateForm(FormMapper $formMapper) $formMapper->add('binaryContent', 'text', array( 'constraints' => array( new NotBlank(), - new NotNull() - ) + new NotNull(), + ), )); } @@ -181,13 +181,13 @@ protected function getMetadata(MediaInterface $media, $url) try { $response = $this->browser->get($url); } catch (\RuntimeException $e) { - throw new \RuntimeException('Unable to retrieve the video information for :' . $url, null, $e); + throw new \RuntimeException('Unable to retrieve the video information for :'.$url, null, $e); } $metadata = json_decode($response->getContent(), true); if (!$metadata) { - throw new \RuntimeException('Unable to decode the video information for :' . $url); + throw new \RuntimeException('Unable to decode the video information for :'.$url); } return $metadata; @@ -211,7 +211,6 @@ protected function getBoxHelperProperties(MediaInterface $media, $format, $optio 'width' => isset($options['width']) ? $options['width'] : null, 'height' => isset($options['height']) ? $options['height'] : null, ); - } else { $settings = $this->getFormat($format); } diff --git a/Provider/DailyMotionProvider.php b/Provider/DailyMotionProvider.php index d6cd31a40..a5f2aa3c2 100644 --- a/Provider/DailyMotionProvider.php +++ b/Provider/DailyMotionProvider.php @@ -90,7 +90,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().".description", "bundles/sonatamedia/dailymotion-icon.png", "SonataMediaBundle"); + return new Metadata($this->getName(), $this->getName().'.description', 'bundles/sonatamedia/dailymotion-icon.png', 'SonataMediaBundle'); } /** diff --git a/Provider/FileProvider.php b/Provider/FileProvider.php index 83839e6eb..df42ce50e 100644 --- a/Provider/FileProvider.php +++ b/Provider/FileProvider.php @@ -11,24 +11,23 @@ namespace Sonata\MediaBundle\Provider; +use Gaufrette\Filesystem; +use Sonata\AdminBundle\Form\FormMapper; use Sonata\CoreBundle\Model\Metadata; -use Sonata\MediaBundle\Extra\ApiMediaFile; -use Sonata\MediaBundle\Model\MediaInterface; +use Sonata\CoreBundle\Validator\ErrorElement; use Sonata\MediaBundle\CDN\CDNInterface; +use Sonata\MediaBundle\Extra\ApiMediaFile; use Sonata\MediaBundle\Generator\GeneratorInterface; -use Sonata\MediaBundle\Thumbnail\ThumbnailInterface; use Sonata\MediaBundle\Metadata\MetadataBuilderInterface; -use Sonata\AdminBundle\Form\FormMapper; -use Sonata\CoreBundle\Validator\ErrorElement; - +use Sonata\MediaBundle\Model\MediaInterface; +use Sonata\MediaBundle\Thumbnail\ThumbnailInterface; +use Symfony\Component\Form\FormBuilder; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\Form\FormBuilder; -use Gaufrette\Filesystem; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotNull; @@ -64,7 +63,7 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().".description", false, "SonataMediaBundle", array('class' => 'fa fa-file-text-o')); + return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', array('class' => 'fa fa-file-text-o')); } /** @@ -108,8 +107,8 @@ public function buildCreateForm(FormMapper $formMapper) $formMapper->add('binaryContent', 'file', array( 'constraints' => array( new NotBlank(), - new NotNull() - ) + new NotNull(), + ), )); } @@ -202,8 +201,6 @@ protected function fixBinaryContent(MediaInterface $media) * @throws \RuntimeException * * @param \Sonata\MediaBundle\Model\MediaInterface $media - * - * @return void */ protected function fixFilename(MediaInterface $media) { @@ -301,12 +298,10 @@ public function generatePrivateUrl(MediaInterface $media, $format) } /** - * Set the file contents for an image + * Set the file contents for an image. * * @param \Sonata\MediaBundle\Model\MediaInterface $media * @param string $contents path to contents, defaults to MediaInterface BinaryContent - * - * @return void */ protected function setFileContents(MediaInterface $media, $contents = null) { @@ -368,7 +363,7 @@ public function getDownloadResponse(MediaInterface $media, $format, $mode, array $file = $this->getFilesystem()->get($this->generatePrivateUrl($media, $format)); } - return new StreamedResponse(function() use ($file) { + return new StreamedResponse(function () use ($file) { echo $file->getContent(); }, 200, $headers); } @@ -412,13 +407,13 @@ public function validate(ErrorElement $errorElement, MediaInterface $media) if (!in_array($media->getBinaryContent()->getMimeType(), $this->allowedMimeTypes)) { $errorElement ->with('binaryContent') - ->addViolation('Invalid mime type : %type%', array("%type%" => $media->getBinaryContent()->getMimeType())) + ->addViolation('Invalid mime type : %type%', array('%type%' => $media->getBinaryContent()->getMimeType())) ->end(); } } /** - * Set media binary content according to request content + * Set media binary content according to request content. * * @param MediaInterface $media */ diff --git a/Provider/ImageProvider.php b/Provider/ImageProvider.php index b002d666f..c3ebc881f 100644 --- a/Provider/ImageProvider.php +++ b/Provider/ImageProvider.php @@ -1,4 +1,5 @@ getName(), $this->getName().".description", false, "SonataMediaBundle", array('class' => 'fa fa-picture-o')); + return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', array('class' => 'fa fa-picture-o')); } /** @@ -74,7 +74,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a 'title' => $media->getName(), 'src' => $this->generatePublicUrl($media, $format), 'width' => $box->getWidth(), - 'height' => $box->getHeight() + 'height' => $box->getHeight(), ), $options); } @@ -114,6 +114,7 @@ protected function doTransform(MediaInterface $media) $image = $this->imagineAdapter->open($media->getBinaryContent()->getPathname()); } catch (\RuntimeException $e) { $media->setProviderStatus(MediaInterface::STATUS_ERROR); + return; } diff --git a/Provider/MediaProviderInterface.php b/Provider/MediaProviderInterface.php index 618bb13a3..6b0f77080 100644 --- a/Provider/MediaProviderInterface.php +++ b/Provider/MediaProviderInterface.php @@ -1,4 +1,5 @@ hasContext($name)) { - return null; + return; } return $this->contexts[$name]; } /** - * Returns the context list + * Returns the context list. * * @return array */ @@ -157,7 +151,7 @@ public function getProviderNamesByContext($name) $context = $this->getContext($name); if (!$context) { - return null; + return; } return $context['providers']; @@ -173,7 +167,7 @@ public function getFormatNamesByContext($name) $context = $this->getContext($name); if (!$context) { - return null; + return; } return $context['formats']; @@ -216,6 +210,7 @@ public function getProviderList() * @param \Sonata\MediaBundle\Model\MediaInterface $media * * @return \Sonata\MediaBundle\Security\DownloadStrategyInterface + * * @throws \RuntimeException */ public function getDownloadSecurity(MediaInterface $media) @@ -225,7 +220,7 @@ public function getDownloadSecurity(MediaInterface $media) $id = $context['download']['strategy']; if (!isset($this->downloadSecurities[$id])) { - throw new \RuntimeException('Unable to retrieve the download security : ' . $id); + throw new \RuntimeException('Unable to retrieve the download security : '.$id); } return $this->downloadSecurities[$id]; @@ -253,9 +248,7 @@ public function getDefaultContext() /** * @param \Sonata\CoreBundle\Validator\ErrorElement $errorElement - * @param \Sonata\MediaBundle\Model\MediaInterface $media - * - * @return void + * @param \Sonata\MediaBundle\Model\MediaInterface $media */ public function validate(ErrorElement $errorElement, MediaInterface $media) { diff --git a/Provider/VimeoProvider.php b/Provider/VimeoProvider.php index 81c987251..a84746c3e 100644 --- a/Provider/VimeoProvider.php +++ b/Provider/VimeoProvider.php @@ -76,7 +76,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().".description", false, "SonataMediaBundle", array('class' => 'fa fa-vimeo-square')); + return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', array('class' => 'fa fa-vimeo-square')); } /** diff --git a/Provider/YouTubeProvider.php b/Provider/YouTubeProvider.php index 858ac58ef..316988f7b 100644 --- a/Provider/YouTubeProvider.php +++ b/Provider/YouTubeProvider.php @@ -11,19 +11,18 @@ namespace Sonata\MediaBundle\Provider; -use Sonata\CoreBundle\Model\Metadata; -use Sonata\MediaBundle\Model\MediaInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; +use Buzz\Browser; use Gaufrette\Filesystem; +use Sonata\CoreBundle\Model\Metadata; use Sonata\MediaBundle\CDN\CDNInterface; use Sonata\MediaBundle\Generator\GeneratorInterface; -use Buzz\Browser; -use Sonata\MediaBundle\Thumbnail\ThumbnailInterface; use Sonata\MediaBundle\Metadata\MetadataBuilderInterface; +use Sonata\MediaBundle\Model\MediaInterface; +use Sonata\MediaBundle\Thumbnail\ThumbnailInterface; +use Symfony\Component\HttpFoundation\RedirectResponse; class YouTubeProvider extends BaseVideoProvider { - /* @var boolean */ protected $html5; @@ -35,7 +34,7 @@ class YouTubeProvider extends BaseVideoProvider * @param \Sonata\MediaBundle\Thumbnail\ThumbnailInterface $thumbnail * @param \Buzz\Browser $browser * @param \Sonata\MediaBundle\Metadata\MetadataBuilderInterface $metadata - * @param boolean $html5 + * @param bool $html5 */ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, GeneratorInterface $pathGenerator, ThumbnailInterface $thumbnail, Browser $browser, MetadataBuilderInterface $metadata = null, $html5 = false) { @@ -48,7 +47,7 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().".description", false, "SonataMediaBundle", array('class' => 'fa fa-youtube')); + return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', array('class' => 'fa fa-youtube')); } /** @@ -155,7 +154,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a // When wmode=window, the Flash movie is not rendered in the page. // When wmode=opaque, the Flash movie is rendered as part of the page. // When wmode=transparent, the Flash movie is rendered as part of the page. - 'wmode' => 'window' + 'wmode' => 'window', ); @@ -179,7 +178,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a // When wmode=window, the Flash movie is not rendered in the page. // When wmode=opaque, the Flash movie is rendered as part of the page. // When wmode=transparent, the Flash movie is rendered as part of the page. - 'wmode' => $default_player_url_parameters['wmode'] + 'wmode' => $default_player_url_parameters['wmode'], ); @@ -188,14 +187,14 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a $box = $this->getBoxHelperProperties($media, $format, $options); $player_parameters = array_merge($default_player_parameters, isset($options['player_parameters']) ? $options['player_parameters'] : array(), array( - 'width' => $box->getWidth(), - 'height' => $box->getHeight() + 'width' => $box->getWidth(), + 'height' => $box->getHeight(), )); $params = array( - 'html5' => $options['html5'], + 'html5' => $options['html5'], 'player_url_parameters' => http_build_query($player_url_parameters), - 'player_parameters' => $player_parameters + 'player_parameters' => $player_parameters, ); return $params; diff --git a/Resizer/ResizerInterface.php b/Resizer/ResizerInterface.php index 26a1f0452..96597b692 100644 --- a/Resizer/ResizerInterface.php +++ b/Resizer/ResizerInterface.php @@ -22,8 +22,6 @@ interface ResizerInterface * @param File $out * @param string $format * @param array $settings - * - * @return void */ public function resize(MediaInterface $media, File $in, File $out, $format, array $settings); diff --git a/Resizer/SimpleResizer.php b/Resizer/SimpleResizer.php index a339e2262..81759d048 100644 --- a/Resizer/SimpleResizer.php +++ b/Resizer/SimpleResizer.php @@ -11,13 +11,13 @@ namespace Sonata\MediaBundle\Resizer; -use Imagine\Image\ImagineInterface; -use Imagine\Image\Box; use Gaufrette\File; -use Sonata\MediaBundle\Model\MediaInterface; -use Imagine\Image\ImageInterface; use Imagine\Exception\InvalidArgumentException; +use Imagine\Image\Box; +use Imagine\Image\ImageInterface; +use Imagine\Image\ImagineInterface; use Sonata\MediaBundle\Metadata\MetadataBuilderInterface; +use Sonata\MediaBundle\Model\MediaInterface; class SimpleResizer implements ResizerInterface { @@ -96,7 +96,7 @@ private function computeBox(MediaInterface $media, array $settings) $ratios = array( $settings['width'] / $size->getWidth(), - $settings['height'] / $size->getHeight() + $settings['height'] / $size->getHeight(), ); if ($this->mode === ImageInterface::THUMBNAIL_INSET) { diff --git a/Resizer/SquareResizer.php b/Resizer/SquareResizer.php index 3530a8d8a..ff90afd4f 100755 --- a/Resizer/SquareResizer.php +++ b/Resizer/SquareResizer.php @@ -11,12 +11,12 @@ namespace Sonata\MediaBundle\Resizer; -use Imagine\Image\ImagineInterface; +use Gaufrette\File; use Imagine\Image\Box; +use Imagine\Image\ImagineInterface; use Imagine\Image\Point; -use Gaufrette\File; -use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Metadata\MetadataBuilderInterface; +use Sonata\MediaBundle\Model\MediaInterface; /** * This reziser crop the image when the width and height are specified. @@ -29,12 +29,12 @@ class SquareResizer implements ResizerInterface { /** - * ImagineInterface + * ImagineInterface. */ protected $adapter; /** - * string + * string. */ protected $mode; @@ -100,7 +100,6 @@ public function getBox(MediaInterface $media, array $settings) $size = $media->getBox(); if (null != $settings['height']) { - if ($size->getHeight() > $size->getWidth()) { $higher = $size->getHeight(); $lower = $size->getWidth(); diff --git a/Resources/config/doctrine/BaseGalleryHasMedia.phpcr.xml b/Resources/config/doctrine/BaseGalleryHasMedia.phpcr.xml index d48a8ca64..efaefce66 100644 --- a/Resources/config/doctrine/BaseGalleryHasMedia.phpcr.xml +++ b/Resources/config/doctrine/BaseGalleryHasMedia.phpcr.xml @@ -18,7 +18,7 @@ - + diff --git a/Resources/views/Provider/view_youtube.html.twig b/Resources/views/Provider/view_youtube.html.twig index afca07b40..b321066bd 100644 --- a/Resources/views/Provider/view_youtube.html.twig +++ b/Resources/views/Provider/view_youtube.html.twig @@ -22,7 +22,7 @@ file that was distributed with this source code. - + getSession()->set($this->sessionKey, $times); diff --git a/SonataMediaBundle.php b/SonataMediaBundle.php index b9da50408..119465a92 100644 --- a/SonataMediaBundle.php +++ b/SonataMediaBundle.php @@ -1,4 +1,5 @@ getProvider($media); diff --git a/Tests/Block/Breadcrumb/BreadcrumbTest.php b/Tests/Block/Breadcrumb/BreadcrumbTest.php index f74e54199..26d31b34b 100644 --- a/Tests/Block/Breadcrumb/BreadcrumbTest.php +++ b/Tests/Block/Breadcrumb/BreadcrumbTest.php @@ -16,7 +16,6 @@ class BreadcrumbGalleryBlockService_Test extends BaseGalleryBreadcrumbBlockService { - } /** diff --git a/Tests/CDN/PantherPortalTest.php b/Tests/CDN/PantherPortalTest.php index 735e964db..6a2cbb98e 100644 --- a/Tests/CDN/PantherPortalTest.php +++ b/Tests/CDN/PantherPortalTest.php @@ -18,7 +18,7 @@ class PantherPortalTest extends \PHPUnit_Framework_TestCase public function testPortal() { $client = $this->getMock('ClientSpy', array('flush'), array(), '', false); - $client->expects($this->exactly(3))->method('flush')->will($this->returnValue("Flush successfully submitted.")); + $client->expects($this->exactly(3))->method('flush')->will($this->returnValue('Flush successfully submitted.')); $panther = new PantherPortal('/foo', 'login', 'pass', 42); $panther->setClient($client); diff --git a/Tests/Controller/Api/GalleryControllerTest.php b/Tests/Controller/Api/GalleryControllerTest.php index 8297f43d2..15c6dfa8e 100644 --- a/Tests/Controller/Api/GalleryControllerTest.php +++ b/Tests/Controller/Api/GalleryControllerTest.php @@ -1,4 +1,5 @@ */ @@ -42,7 +39,7 @@ public function testGetGalleriesAction() $gController = new GalleryController($gManager, $mediaManager, $formFactory, 'test'); $params = $this->getMock('FOS\RestBundle\Request\ParamFetcherInterface'); - $params->expects($this->once())->method('all')->will($this->returnValue(array('page' => 1, 'count' => 10, 'orderBy' => array('id' => "ASC")))); + $params->expects($this->once())->method('all')->will($this->returnValue(array('page' => 1, 'count' => 10, 'orderBy' => array('id' => 'ASC')))); $params->expects($this->exactly(3))->method('get'); $this->assertEquals(array(), $gController->getGalleriesAction($params)); diff --git a/Tests/Controller/Api/MediaControllerTest.php b/Tests/Controller/Api/MediaControllerTest.php index c3563fbf5..47819786e 100644 --- a/Tests/Controller/Api/MediaControllerTest.php +++ b/Tests/Controller/Api/MediaControllerTest.php @@ -1,4 +1,5 @@ */ @@ -33,7 +32,7 @@ public function testGetMediaAction() $mController = $this->createMediaController($mManager); $params = $this->getMock('FOS\RestBundle\Request\ParamFetcherInterface'); - $params->expects($this->once())->method('all')->will($this->returnValue(array('page' => 1, 'count' => 10, 'orderBy' => array('id' => "ASC")))); + $params->expects($this->once())->method('all')->will($this->returnValue(array('page' => 1, 'count' => 10, 'orderBy' => array('id' => 'ASC')))); $params->expects($this->exactly(3))->method('get'); $this->assertEquals(array($media), $mController->getMediaAction($params)); @@ -72,20 +71,20 @@ public function testGetMediumFormatsAction() $pool = $this->getMockBuilder('Sonata\MediaBundle\Provider\Pool')->disableOriginalConstructor()->getMock(); $pool->expects($this->any())->method('getProvider')->will($this->returnValue($provider)); - $pool->expects($this->once())->method('getFormatNamesByContext')->will($this->returnValue(array('format_name1' => "value1"))); + $pool->expects($this->once())->method('getFormatNamesByContext')->will($this->returnValue(array('format_name1' => 'value1'))); $controller = $this->createMediaController($manager, $pool); $expected = array( 'reference' => array( 'properties' => array( - 'foo' => "bar" + 'foo' => 'bar', ), 'url' => null, ), - 'format_name1' =>array( + 'format_name1' => array( 'properties' => array( - 'foo' => "bar" + 'foo' => 'bar', ), 'url' => null, ), @@ -201,7 +200,7 @@ public function testPostProviderMediumAction() $controller = $this->createMediaController($manager, $pool, $factory); - $this->assertInstanceOf('FOS\RestBundle\View\View', $controller->postProviderMediumAction("providerName", new Request())); + $this->assertInstanceOf('FOS\RestBundle\View\View', $controller->postProviderMediumAction('providerName', new Request())); } /** @@ -216,10 +215,10 @@ public function testPostProviderActionNotFound() $manager->expects($this->once())->method('create')->will($this->returnValue($medium)); $pool = $this->getMockBuilder('Sonata\MediaBundle\Provider\Pool')->disableOriginalConstructor()->getMock(); - $pool->expects($this->once())->method('getProvider')->will($this->throwException(new \RuntimeException("exception on getProvder"))); + $pool->expects($this->once())->method('getProvider')->will($this->throwException(new \RuntimeException('exception on getProvder'))); $controller = $this->createMediaController($manager, $pool); - $controller->postProviderMediumAction("non existing provider", new Request()); + $controller->postProviderMediumAction('non existing provider', new Request()); } public function testPutMediumBinaryContentAction() diff --git a/Tests/Entity/GalleryManagerTest.php b/Tests/Entity/GalleryManagerTest.php index e0d968c04..819c20c58 100644 --- a/Tests/Entity/GalleryManagerTest.php +++ b/Tests/Entity/GalleryManagerTest.php @@ -1,4 +1,5 @@ */ @@ -82,7 +82,7 @@ public function testGetPagerWithMultipleSort() $qb->expects($self->once())->method('setParameters')->with($self->equalTo(array())); }) ->getPager(array(), 1, 10, array( - 'name' => 'ASC', + 'name' => 'ASC', 'context' => 'DESC', )); } diff --git a/Tests/Entity/Media.php b/Tests/Entity/Media.php index 40cc99d23..303917146 100644 --- a/Tests/Entity/Media.php +++ b/Tests/Entity/Media.php @@ -13,7 +13,6 @@ class Media extends \Sonata\MediaBundle\Entity\BaseMedia { - protected $id; public function setId($id) diff --git a/Tests/Entity/MediaManagerTest.php b/Tests/Entity/MediaManagerTest.php index 7ba4a6639..e8419133b 100644 --- a/Tests/Entity/MediaManagerTest.php +++ b/Tests/Entity/MediaManagerTest.php @@ -1,4 +1,5 @@ */ @@ -78,7 +78,7 @@ public function testGetPagerWithMultipleSort() $qb->expects($self->once())->method('setParameters')->with($self->equalTo(array())); }) ->getPager(array(), 1, 10, array( - 'name' => 'ASC', + 'name' => 'ASC', 'description' => 'DESC', )); } diff --git a/Tests/Entity/MediaTest.php b/Tests/Entity/MediaTest.php index 934e5828b..ffa67e232 100644 --- a/Tests/Entity/MediaTest.php +++ b/Tests/Entity/MediaTest.php @@ -15,8 +15,7 @@ class MediaTest extends \PHPUnit_Framework_TestCase { public function testMetadata() { - - $media = new Media; + $media = new Media(); $media->setProviderMetadata(array('thumbnail_url' => 'http://pasloin.com/thumb.png')); @@ -34,7 +33,7 @@ public function testStatusList() public function testSetGet() { - $media = new Media; + $media = new Media(); $media->setName('MediaBundle'); $media->setSize(12); $media->setDescription('description'); @@ -45,9 +44,9 @@ public function testSetGet() $media->setAuthorName('Thomas'); $media->setCdnIsFlushable(true); $media->setCdnFlushIdentifier('identifier_123'); - $media->setCdnFlushAt(new \DateTime); + $media->setCdnFlushAt(new \DateTime()); $media->setContentType('sonata/media'); - $media->setCreatedAt(new \DateTime); + $media->setCreatedAt(new \DateTime()); $this->assertEquals(12, $media->getSize()); $this->assertEquals('description', $media->getDescription()); @@ -64,7 +63,5 @@ public function testSetGet() $this->assertEquals('MediaBundle', (string) $media); $this->assertNull($media->getMetadataValue('foo')); - } - } diff --git a/Tests/Filesystem/ReplicateTest.php b/Tests/Filesystem/ReplicateTest.php index 32efe5496..ed0a2732d 100644 --- a/Tests/Filesystem/ReplicateTest.php +++ b/Tests/Filesystem/ReplicateTest.php @@ -13,7 +13,7 @@ use Sonata\MediaBundle\Filesystem\Replicate; -class MediaTest extends \PHPUnit_Framework_TestCase +class ReplicateTest extends \PHPUnit_Framework_TestCase { public function testReplicate() { diff --git a/Tests/Form/DataTransformer/ProviderDataTransformerTest.php b/Tests/Form/DataTransformer/ProviderDataTransformerTest.php index 4c99d0872..4f5f5cb31 100644 --- a/Tests/Form/DataTransformer/ProviderDataTransformerTest.php +++ b/Tests/Form/DataTransformer/ProviderDataTransformerTest.php @@ -39,7 +39,7 @@ public function testReverseTransformUnknownProvider() $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue('xcs')); $transformer = new ProviderDataTransformer($pool, 'stdClass', array( - 'new_on_update' => false + 'new_on_update' => false, )); $transformer->reverseTransform($media); } @@ -58,7 +58,7 @@ public function testReverseTransformValidProvider() $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue('xcs')); $transformer = new ProviderDataTransformer($pool, 'stdClass', array( - 'new_on_update' => false + 'new_on_update' => false, )); $transformer->reverseTransform($media); } @@ -79,7 +79,7 @@ public function testReverseTransformWithNewMediaAndNoBinaryContent() $transformer = new ProviderDataTransformer($pool, 'stdClass', array( 'new_on_update' => false, - 'empty_on_new' => false + 'empty_on_new' => false, )); $this->assertEquals($media, $transformer->reverseTransform($media)); } @@ -111,9 +111,8 @@ public function testReverseTransformWithMediaAndUploadFileInstance() $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue(new UploadedFile(__FILE__, 'ProviderDataTransformerTest'))); $transformer = new ProviderDataTransformer($pool, 'stdClass', array( - 'new_on_update' => false + 'new_on_update' => false, )); $transformer->reverseTransform($media); - } } diff --git a/Tests/Form/Type/ApiMediaTypeTest.php b/Tests/Form/Type/ApiMediaTypeTest.php index 73931e963..eb8e7d87f 100644 --- a/Tests/Form/Type/ApiMediaTypeTest.php +++ b/Tests/Form/Type/ApiMediaTypeTest.php @@ -1,4 +1,5 @@ */ @@ -30,11 +28,11 @@ public function testBuildForm() $mediaPool = $this->getMockBuilder('Sonata\MediaBundle\Provider\Pool')->disableOriginalConstructor()->getMock(); $mediaPool->expects($this->once())->method('getProvider')->will($this->returnValue($provider)); - $type = new ApiMediaType($mediaPool, "testclass"); + $type = new ApiMediaType($mediaPool, 'testclass'); $builder = $this->getMockBuilder('Symfony\Component\Form\FormBuilder')->disableOriginalConstructor()->getMock(); $builder->expects($this->once())->method('addModelTransformer'); - $type->buildForm($builder, array("provider_name" => "sonata.media.provider.image")); + $type->buildForm($builder, array('provider_name' => 'sonata.media.provider.image')); } } diff --git a/Tests/Generator/DefaultGeneratorTest.php b/Tests/Generator/DefaultGeneratorTest.php index 00a7f3b54..d7c540359 100644 --- a/Tests/Generator/DefaultGeneratorTest.php +++ b/Tests/Generator/DefaultGeneratorTest.php @@ -16,13 +16,11 @@ class DefaultGeneratorTest extends \PHPUnit_Framework_TestCase { - public function testProvider() { + $generator = new DefaultGenerator(); - $generator = new DefaultGenerator; - - $media = new Media; + $media = new Media(); $media->setContext('user'); $media->setId(10); @@ -36,6 +34,5 @@ public function testProvider() $media->setId(999999999); $this->assertEquals('user/10000/100', $generator->generatePath($media)); - } } diff --git a/Tests/Generator/PHPCRGeneratorTest.php b/Tests/Generator/PHPCRGeneratorTest.php index 70d0f73e0..f9705dd29 100644 --- a/Tests/Generator/PHPCRGeneratorTest.php +++ b/Tests/Generator/PHPCRGeneratorTest.php @@ -16,13 +16,11 @@ class PHPCRGeneratorTest extends \PHPUnit_Framework_TestCase { - public function testPHPCRGenerator() { + $generator = new PHPCRGenerator(); - $generator = new PHPCRGenerator; - - $media = new Media; + $media = new Media(); $media->setContext('user'); $media->setId('nodename'); diff --git a/Tests/Metadata/AmazonMetadataBuilderTest.php b/Tests/Metadata/AmazonMetadataBuilderTest.php index 3f373792e..4061c3f41 100644 --- a/Tests/Metadata/AmazonMetadataBuilderTest.php +++ b/Tests/Metadata/AmazonMetadataBuilderTest.php @@ -11,16 +11,16 @@ namespace Sonata\MediaBundle\Tests\Metadata; -use Sonata\MediaBundle\Metadata\AmazonMetadataBuilder; use Aws\S3\Enum\CannedAcl; use Aws\S3\Enum\Storage; +use Sonata\MediaBundle\Metadata\AmazonMetadataBuilder; class AmazonMetadataBuilderTest extends \PHPUnit_Framework_TestCase { public function setUp() { if (!class_exists('Aws\S3\Enum\CannedAcl')) { - $this->markTestSkipped("Missing Aws\\S3\\Enum\\CannedAcl"); + $this->markTestSkipped('Missing Aws\\S3\\Enum\\CannedAcl'); } } @@ -42,18 +42,18 @@ public function testAmazon() public function provider() { return array( - array(array('acl' => 'private'), array('ACL' => CannedAcl::PRIVATE_ACCESS, 'contentType' => 'image/png')), - array(array('acl' => 'public'), array('ACL' => CannedAcl::PUBLIC_READ, 'contentType' => 'image/png')), - array(array('acl' => 'open'), array('ACL' => CannedAcl::PUBLIC_READ_WRITE, 'contentType' => 'image/png')), - array(array('acl' => 'auth_read'), array('ACL' => CannedAcl::AUTHENTICATED_READ, 'contentType' => 'image/png')), - array(array('acl' => 'owner_read'), array('ACL' => CannedAcl::BUCKET_OWNER_READ, 'contentType' => 'image/png')), - array(array('acl' => 'owner_full_control'), array('ACL' => CannedAcl::BUCKET_OWNER_FULL_CONTROL, 'contentType' => 'image/png')), - array(array('storage' => 'standard'), array('storage' => Storage::STANDARD, 'contentType' => 'image/png')), - array(array('storage' => 'reduced'), array('storage' => Storage::REDUCED, 'contentType' => 'image/png')), + array(array('acl' => 'private'), array('ACL' => CannedAcl::PRIVATE_ACCESS, 'contentType' => 'image/png')), + array(array('acl' => 'public'), array('ACL' => CannedAcl::PUBLIC_READ, 'contentType' => 'image/png')), + array(array('acl' => 'open'), array('ACL' => CannedAcl::PUBLIC_READ_WRITE, 'contentType' => 'image/png')), + array(array('acl' => 'auth_read'), array('ACL' => CannedAcl::AUTHENTICATED_READ, 'contentType' => 'image/png')), + array(array('acl' => 'owner_read'), array('ACL' => CannedAcl::BUCKET_OWNER_READ, 'contentType' => 'image/png')), + array(array('acl' => 'owner_full_control'), array('ACL' => CannedAcl::BUCKET_OWNER_FULL_CONTROL, 'contentType' => 'image/png')), + array(array('storage' => 'standard'), array('storage' => Storage::STANDARD, 'contentType' => 'image/png')), + array(array('storage' => 'reduced'), array('storage' => Storage::REDUCED, 'contentType' => 'image/png')), array(array('cache_control' => 'max-age=86400'), array('CacheControl' => 'max-age=86400', 'contentType' => 'image/png')), - array(array('encryption' => 'aes256'), array('encryption' => 'AES256', 'contentType' => 'image/png')), - array(array('meta' => array('key' => 'value')), array('meta' => array('key' => 'value'), 'contentType' => 'image/png')), - array(array('acl' => 'public', 'storage' => 'standard', 'cache_control' => 'max-age=86400', 'encryption' => 'aes256', 'meta' => array('key' => 'value')), array('ACL' => CannedAcl::PUBLIC_READ, 'contentType' => 'image/png', 'storage' => Storage::STANDARD, 'CacheControl' => 'max-age=86400', 'encryption' => 'AES256', 'meta' => array('key' => 'value'))) + array(array('encryption' => 'aes256'), array('encryption' => 'AES256', 'contentType' => 'image/png')), + array(array('meta' => array('key' => 'value')), array('meta' => array('key' => 'value'), 'contentType' => 'image/png')), + array(array('acl' => 'public', 'storage' => 'standard', 'cache_control' => 'max-age=86400', 'encryption' => 'aes256', 'meta' => array('key' => 'value')), array('ACL' => CannedAcl::PUBLIC_READ, 'contentType' => 'image/png', 'storage' => Storage::STANDARD, 'CacheControl' => 'max-age=86400', 'encryption' => 'AES256', 'meta' => array('key' => 'value'))), ); } } diff --git a/Tests/Metadata/NoopMetadataBuilderTest.php b/Tests/Metadata/NoopMetadataBuilderTest.php index 1ca7e3b90..0a7f80fbb 100644 --- a/Tests/Metadata/NoopMetadataBuilderTest.php +++ b/Tests/Metadata/NoopMetadataBuilderTest.php @@ -12,7 +12,6 @@ namespace Sonata\MediaBundle\Tests\Metadata; use Sonata\MediaBundle\Metadata\NoopMetadataBuilder; -use Sonata\MediaBundle\Model\MediaInterface; class NoopMetadataBuilderTest extends \PHPUnit_Framework_TestCase { @@ -25,5 +24,4 @@ public function testNoop() $this->assertEquals(array(), $noopmetadatabuilder->get($media, $filename)); } - } diff --git a/Tests/Metadata/ProxyMetadataBuilderTest.php b/Tests/Metadata/ProxyMetadataBuilderTest.php index 260226046..5e533970d 100644 --- a/Tests/Metadata/ProxyMetadataBuilderTest.php +++ b/Tests/Metadata/ProxyMetadataBuilderTest.php @@ -11,16 +11,11 @@ namespace Sonata\MediaBundle\Tests\Metadata; +use AmazonS3 as AmazonClient; +use Gaufrette\Adapter\AmazonS3; use Sonata\MediaBundle\Filesystem\Local; use Sonata\MediaBundle\Filesystem\Replicate; use Sonata\MediaBundle\Metadata\ProxyMetadataBuilder; -use Sonata\MediaBundle\Metadata\AmazonMetadataBuilder; -use Sonata\MediaBundle\Metadata\NoopMetadataBuilder; -use Gaufrette\Adapter\AmazonS3; -use \AmazonS3 as AmazonClient; -use Gaufrette\Filesystem; -use Sonata\MediaBundle\Model\MediaInterface; -use Sonata\MediaBundle\Provider\MediaProviderInterface; class ProxyMetadataBuilderTest extends \PHPUnit_Framework_TestCase { @@ -36,12 +31,12 @@ public function testProxyAmazon() $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->once()) ->method('get') - ->will($this->returnValue(array('key'=>'amazon'))); + ->will($this->returnValue(array('key' => 'amazon'))); $noop = $this->getMock('Sonata\MediaBundle\Metadata\NoopMetadataBuilder'); $noop->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key'=>'noop'))); + ->will($this->returnValue(array('key' => 'noop'))); //adapter cannot be mocked $amazonclient = new AmazonClient(array('key' => 'XXXXXXXXXXXX', 'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')); @@ -61,14 +56,14 @@ public function testProxyAmazon() $filename = '/test/folder/testfile.png'; $container = $this->getContainerMock(array( - 'sonata.media.metadata.noop' => $noop, + 'sonata.media.metadata.noop' => $noop, 'sonata.media.metadata.amazon' => $amazon, - 'sonata.media.provider.image' => $provider + 'sonata.media.provider.image' => $provider, )); $proxymetadatabuilder = new ProxyMetadataBuilder($container, array()); - $this->assertEquals(array('key'=>'amazon'), $proxymetadatabuilder->get($media, $filename)); + $this->assertEquals(array('key' => 'amazon'), $proxymetadatabuilder->get($media, $filename)); } public function testProxyLocal() @@ -76,12 +71,12 @@ public function testProxyLocal() $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key'=>'amazon'))); + ->will($this->returnValue(array('key' => 'amazon'))); $noop = $this->getMock('Sonata\MediaBundle\Metadata\NoopMetadataBuilder'); $noop->expects($this->once()) ->method('get') - ->will($this->returnValue(array('key'=>'noop'))); + ->will($this->returnValue(array('key' => 'noop'))); //adapter cannot be mocked $adapter = new Local(''); @@ -100,14 +95,14 @@ public function testProxyLocal() $filename = '/test/folder/testfile.png'; $container = $this->getContainerMock(array( - 'sonata.media.metadata.noop' => $noop, + 'sonata.media.metadata.noop' => $noop, 'sonata.media.metadata.amazon' => $amazon, - 'sonata.media.provider.image' => $provider + 'sonata.media.provider.image' => $provider, )); $proxymetadatabuilder = new ProxyMetadataBuilder($container, array()); - $this->assertEquals(array('key'=>'noop'), $proxymetadatabuilder->get($media, $filename)); + $this->assertEquals(array('key' => 'noop'), $proxymetadatabuilder->get($media, $filename)); } public function testProxyNoProvider() @@ -115,12 +110,12 @@ public function testProxyNoProvider() $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key'=>'amazon'))); + ->will($this->returnValue(array('key' => 'amazon'))); $noop = $this->getMock('Sonata\MediaBundle\Metadata\NoopMetadataBuilder'); $noop->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key'=>'noop'))); + ->will($this->returnValue(array('key' => 'noop'))); //adapter cannot be mocked $adapter = new Local(''); @@ -139,9 +134,9 @@ public function testProxyNoProvider() $filename = '/test/folder/testfile.png'; $container = $this->getContainerMock(array( - 'sonata.media.metadata.noop' => $noop, + 'sonata.media.metadata.noop' => $noop, 'sonata.media.metadata.amazon' => $amazon, - 'sonata.media.provider.image' => $provider + 'sonata.media.provider.image' => $provider, )); $proxymetadatabuilder = new ProxyMetadataBuilder($container, array()); @@ -154,12 +149,12 @@ public function testProxyReplicateWithAmazon() $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->once()) ->method('get') - ->will($this->returnValue(array('key'=>'amazon'))); + ->will($this->returnValue(array('key' => 'amazon'))); $noop = $this->getMock('Sonata\MediaBundle\Metadata\NoopMetadataBuilder'); $noop->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key'=>'noop'))); + ->will($this->returnValue(array('key' => 'noop'))); //adapter cannot be mocked $amazonclient = new AmazonClient(array('key' => 'XXXXXXXXXXXX', 'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')); @@ -181,14 +176,14 @@ public function testProxyReplicateWithAmazon() $filename = '/test/folder/testfile.png'; $container = $this->getContainerMock(array( - 'sonata.media.metadata.noop' => $noop, + 'sonata.media.metadata.noop' => $noop, 'sonata.media.metadata.amazon' => $amazon, - 'sonata.media.provider.image' => $provider + 'sonata.media.provider.image' => $provider, )); $proxymetadatabuilder = new ProxyMetadataBuilder($container, array()); - $this->assertEquals(array('key'=>'amazon'), $proxymetadatabuilder->get($media, $filename)); + $this->assertEquals(array('key' => 'amazon'), $proxymetadatabuilder->get($media, $filename)); } public function testProxyReplicateWithoutAmazon() @@ -196,12 +191,12 @@ public function testProxyReplicateWithoutAmazon() $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key'=>'amazon'))); + ->will($this->returnValue(array('key' => 'amazon'))); $noop = $this->getMock('Sonata\MediaBundle\Metadata\NoopMetadataBuilder'); $noop->expects($this->once()) ->method('get') - ->will($this->returnValue(array('key'=>'noop'))); + ->will($this->returnValue(array('key' => 'noop'))); //adapter cannot be mocked $adapter1 = new Local(''); @@ -222,37 +217,37 @@ public function testProxyReplicateWithoutAmazon() $filename = '/test/folder/testfile.png'; $container = $this->getContainerMock(array( - 'sonata.media.metadata.noop' => $noop, + 'sonata.media.metadata.noop' => $noop, 'sonata.media.metadata.amazon' => $amazon, - 'sonata.media.provider.image' => $provider + 'sonata.media.provider.image' => $provider, )); $proxymetadatabuilder = new ProxyMetadataBuilder($container, array()); - $this->assertEquals(array('key'=>'noop'), $proxymetadatabuilder->get($media, $filename)); + $this->assertEquals(array('key' => 'noop'), $proxymetadatabuilder->get($media, $filename)); } /** - * Return a mock object for the DI ContainerInterface. - * - * @param array $services A key-value list of services the container contains. - * - * @return \PHPUnit_Framework_MockObject_MockObject - */ + * Return a mock object for the DI ContainerInterface. + * + * @param array $services A key-value list of services the container contains. + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getContainerMock(array $services) { $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container ->expects($this->any()) ->method('get') - ->will($this->returnCallback(function($service) use ($services) { + ->will($this->returnCallback(function ($service) use ($services) { return $services[$service]; })) ; $container ->expects($this->any()) ->method('has') - ->will($this->returnCallback(function($service) use ($services) { + ->will($this->returnCallback(function ($service) use ($services) { if (isset($services[$service])) { return true; } diff --git a/Tests/Model/MediaTest.php b/Tests/Model/MediaTest.php index a79693cf1..4607cd3c5 100644 --- a/Tests/Model/MediaTest.php +++ b/Tests/Model/MediaTest.php @@ -24,9 +24,9 @@ public function testSetMetadataValue() $this->assertSame('value', $metadata['name'], 'the string value should be returned'); $cropData = array( - 'x' => 10, - 'y' => 20, - 'width' => 500, + 'x' => 10, + 'y' => 20, + 'width' => 500, 'height' => 500, ); $media->setMetadataValue('crop', $cropData); diff --git a/Tests/Provider/BaseProviderTest.php b/Tests/Provider/BaseProviderTest.php index a6eca2a2b..91d241723 100644 --- a/Tests/Provider/BaseProviderTest.php +++ b/Tests/Provider/BaseProviderTest.php @@ -11,10 +11,10 @@ namespace Sonata\MediaBundle\Tests\Provider; -use Sonata\MediaBundle\Tests\Entity\Media; -use Sonata\MediaBundle\Provider\BaseProvider; -use Sonata\MediaBundle\Model\MediaInterface; use Sonata\AdminBundle\Form\FormMapper; +use Sonata\MediaBundle\Model\MediaInterface; +use Sonata\MediaBundle\Provider\BaseProvider; +use Sonata\MediaBundle\Tests\Entity\Media; use Symfony\Component\Form\FormBuilder; class BaseProviderTest extends \PHPUnit_Framework_TestCase @@ -47,7 +47,7 @@ public function testBaseProvider() { $provider = $this->getProvider(); $provider->setTemplates(array( - 'edit' => 'edit.twig' + 'edit' => 'edit.twig', )); $this->assertInternalType('array', $provider->getTemplates()); @@ -59,7 +59,7 @@ public function testBaseProvider() $this->assertInternalType('array', $provider->getFormat('small')); - $media = new \Sonata\MediaBundle\Tests\Entity\Media; + $media = new \Sonata\MediaBundle\Tests\Entity\Media(); $media->setContext('test'); $this->assertEquals('admin', $provider->getFormatName($media, 'admin')); @@ -78,11 +78,11 @@ public function testMetadata() { $provider = $this->getProvider(); - $this->assertEquals("test", $provider->getProviderMetadata()->getTitle()); - $this->assertEquals("test.description", $provider->getProviderMetadata()->getDescription()); + $this->assertEquals('test', $provider->getProviderMetadata()->getTitle()); + $this->assertEquals('test.description', $provider->getProviderMetadata()->getDescription()); $this->assertFalse($provider->getProviderMetadata()->getImage()); - $this->assertEquals("fa fa-file", $provider->getProviderMetadata()->getOption('class')); - $this->assertEquals("SonataMediaBundle", $provider->getProviderMetadata()->getDomain()); + $this->assertEquals('fa fa-file', $provider->getProviderMetadata()->getOption('class')); + $this->assertEquals('SonataMediaBundle', $provider->getProviderMetadata()->getDomain()); } } @@ -149,7 +149,7 @@ public function getReferenceImage(MediaInterface $media) */ public function generatePrivateUrl(MediaInterface $media, $format) { - // TODO: Implement generatePrivateUrl() method. + // TODO: Implement generatePrivateUrl() method. } /** @@ -157,7 +157,7 @@ public function generatePrivateUrl(MediaInterface $media, $format) */ public function generatePublicUrl(MediaInterface $media, $format) { - // TODO: Implement generatePublicUrl() method. + // TODO: Implement generatePublicUrl() method. } /** @@ -165,7 +165,7 @@ public function generatePublicUrl(MediaInterface $media, $format) */ public function getReferenceFile(MediaInterface $media) { - // TODO: Implement getReferenceFile() method. + // TODO: Implement getReferenceFile() method. } /** diff --git a/Tests/Provider/DailyMotionProviderTest.php b/Tests/Provider/DailyMotionProviderTest.php index fea4137c0..45a9987aa 100644 --- a/Tests/Provider/DailyMotionProviderTest.php +++ b/Tests/Provider/DailyMotionProviderTest.php @@ -11,12 +11,12 @@ namespace Sonata\MediaBundle\Tests\Provider; -use Sonata\MediaBundle\Tests\Entity\Media; -use Sonata\MediaBundle\Provider\DailyMotionProvider; -use Sonata\MediaBundle\Thumbnail\FormatThumbnail; use Buzz\Browser; use Buzz\Message\Response; use Imagine\Image\Box; +use Sonata\MediaBundle\Provider\DailyMotionProvider; +use Sonata\MediaBundle\Tests\Entity\Media; +use Sonata\MediaBundle\Thumbnail\FormatThumbnail; class DailyMotionProviderTest extends \PHPUnit_Framework_TestCase { @@ -54,7 +54,7 @@ public function testProvider() { $provider = $this->getProvider(); - $media = new Media; + $media = new Media(); $media->setName('les tests fonctionnels - Symfony Live 2009'); $media->setProviderName('dailymotion'); $media->setProviderReference('x9wjql'); @@ -80,7 +80,7 @@ public function testThumbnail() $provider = $this->getProvider($browser); - $media = new Media; + $media = new Media(); $media->setName('les tests fonctionnels - Symfony Live 2009'); $media->setProviderName('dailymotion'); $media->setProviderReference('x9wjql'); @@ -112,7 +112,7 @@ public function testTransformWithSig() $provider->addFormat('big', array('width' => 200, 'height' => null, 'constraint' => true)); - $media = new Media; + $media = new Media(); $media->setBinaryContent('x9wjql'); $media->setId(1023456); @@ -135,7 +135,7 @@ public function testTransformWithUrl() $provider->addFormat('big', array('width' => 200, 'height' => null, 'constraint' => true)); - $media = new Media; + $media = new Media(); $media->setBinaryContent('http://www.dailymotion.com/video/x9wjql_asdasdasdsa_asdsds'); $media->setId(1023456); @@ -174,7 +174,7 @@ public function testHelperProperies() $provider = $this->getProvider(); $provider->addFormat('admin', array('width' => 100)); - $media = new Media; + $media = new Media(); $media->setName('Les tests'); $media->setProviderReference('ASDASDAS.png'); $media->setId(10); diff --git a/Tests/Provider/FakeHttpWrapper.php b/Tests/Provider/FakeHttpWrapper.php index 8f22a3d0b..e5ac3b4ed 100644 --- a/Tests/Provider/FakeHttpWrapper.php +++ b/Tests/Provider/FakeHttpWrapper.php @@ -16,15 +16,15 @@ class FakeHttpWrapper public static $ref = array( // youtube content 'http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=BDYAbAtaDzA&format=json' => 'valide_youtube.txt', - 'http://i3.ytimg.com/vi/BDYAbAtaDzA/hqdefault.jpg' => 'logo.jpg', + 'http://i3.ytimg.com/vi/BDYAbAtaDzA/hqdefault.jpg' => 'logo.jpg', // dailymotion content - 'http://www.dailymotion.com/services/oembed?url=http://www.dailymotion.com/video/x9wjql&format=json' => 'valide_dailymotion.txt', + 'http://www.dailymotion.com/services/oembed?url=http://www.dailymotion.com/video/x9wjql&format=json' => 'valide_dailymotion.txt', 'http://ak2.static.dailymotion.com/static/video/711/536/16635117:jpeg_preview_large.jpg?20100801072241' => 'logo.jpg', // vimeo content 'http://vimeo.com/api/oembed.json?url=http://vimeo.com/BDYAbAtaDzA' => 'valide_vimeo.txt', - 'http://b.vimeocdn.com/ts/136/375/136375440_1280.jpg' => 'logo.jpg', + 'http://b.vimeocdn.com/ts/136/375/136375440_1280.jpg' => 'logo.jpg', ); /* Properties */ @@ -109,27 +109,27 @@ public function stream_seek($offset, $whence = SEEK_SET) { } - public function stream_set_option($option, $arg1, $arg2) + public function stream_set_option($option, $arg1, $arg2) { } - public function stream_stat() + public function stream_stat() { } - public function stream_tell() + public function stream_tell() { } - public function stream_write($data) + public function stream_write($data) { } - public function unlink($path) + public function unlink($path) { } - public function url_stat($path, $flags) + public function url_stat($path, $flags) { } } diff --git a/Tests/Provider/FileProviderTest.php b/Tests/Provider/FileProviderTest.php index 272f7b90a..1f0a8d9a9 100644 --- a/Tests/Provider/FileProviderTest.php +++ b/Tests/Provider/FileProviderTest.php @@ -11,15 +11,14 @@ namespace Sonata\MediaBundle\Tests\Provider; -use Symfony\Component\HttpFoundation\File\File; -use Sonata\MediaBundle\Tests\Entity\Media; use Sonata\MediaBundle\Provider\FileProvider; +use Sonata\MediaBundle\Tests\Entity\Media; use Sonata\MediaBundle\Thumbnail\FormatThumbnail; +use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\Request; class FileProviderTest extends \PHPUnit_Framework_TestCase { - public function getProvider() { $resizer = $this->getMock('Sonata\MediaBundle\Resizer\ResizerInterface'); @@ -50,7 +49,7 @@ public function testProvider() { $provider = $this->getProvider(); - $media = new Media; + $media = new Media(); $media->setName('test.txt'); $media->setProviderReference('ASDASD.txt'); $media->setContext('default'); @@ -69,7 +68,7 @@ public function testHelperProperies() $provider = $this->getProvider(); $provider->addFormat('admin', array('width' => 100)); - $media = new Media; + $media = new Media(); $media->setName('test.png'); $media->setProviderReference('ASDASDAS.png'); $media->setId(10); @@ -107,7 +106,7 @@ public function testThumbnail() { $provider = $this->getProvider(); - $media = new Media; + $media = new Media(); $media->setName('test.png'); $media->setId(1023456); @@ -122,7 +121,7 @@ public function testEvent() $file = __DIR__.'/../fixtures/file.txt'; - $media = new Media; + $media = new Media(); $provider->preUpdate($media); $this->assertNull($media->getProviderReference()); @@ -136,7 +135,7 @@ public function testEvent() $file = new \Symfony\Component\HttpFoundation\File\File(realpath(__DIR__.'/../fixtures/file.txt')); - $media = new Media; + $media = new Media(); $media->setBinaryContent($file); $media->setId(1023456); @@ -156,7 +155,7 @@ public function testDownload() $file = new File(realpath(__DIR__.'/../fixtures/FileProviderTest/0011/24/file.txt')); - $media = new Media; + $media = new Media(); $media->setBinaryContent($file); $media->setProviderReference('file.txt'); $media->setContext('FileProviderTest'); @@ -169,15 +168,14 @@ public function testDownload() /** * @dataProvider mediaProvider - * */ public function testTransform($expected, $media, $overridePhpSapiName = true) { $self = $this; - $closure = function() use ($self, $expected, $media, $overridePhpSapiName){ + $closure = function () use ($self, $expected, $media, $overridePhpSapiName) { if ($overridePhpSapiName) { - require_once ('phpSapiNameOverride.php'); + require_once 'phpSapiNameOverride.php'; } $provider = $self->getProvider(); diff --git a/Tests/Provider/ImageProviderTest.php b/Tests/Provider/ImageProviderTest.php index a959351e7..045eb7ecc 100644 --- a/Tests/Provider/ImageProviderTest.php +++ b/Tests/Provider/ImageProviderTest.php @@ -11,15 +11,13 @@ namespace Sonata\MediaBundle\Tests\Provider; -use Sonata\MediaBundle\Model\MediaInterface; -use Sonata\MediaBundle\Tests\Entity\Media; +use Imagine\Image\Box; use Sonata\MediaBundle\Provider\ImageProvider; +use Sonata\MediaBundle\Tests\Entity\Media; use Sonata\MediaBundle\Thumbnail\FormatThumbnail; -use Imagine\Image\Box; class ImageProviderTest extends \PHPUnit_Framework_TestCase { - public function getProvider($allowedExtensions = array(), $allowedMimeTypes = array()) { $resizer = $this->getMock('Sonata\MediaBundle\Resizer\ResizerInterface'); @@ -60,7 +58,7 @@ public function testProvider() { $provider = $this->getProvider(); - $media = new Media; + $media = new Media(); $media->setName('test.png'); $media->setProviderReference('ASDASDAS.png'); $media->setId(1023456); @@ -78,7 +76,7 @@ public function testHelperProperies() $provider = $this->getProvider(); $provider->addFormat('admin', array('width' => 100)); - $media = new Media; + $media = new Media(); $media->setName('test.png'); $media->setProviderReference('ASDASDAS.png'); $media->setId(10); @@ -92,7 +90,7 @@ public function testHelperProperies() $this->assertEquals(100, $properties['width']); $properties = $provider->getHelperProperties($media, 'admin', array( - 'width' => 150 + 'width' => 150, )); $this->assertEquals(150, $properties['width']); @@ -102,7 +100,7 @@ public function testThumbnail() { $provider = $this->getProvider(); - $media = new Media; + $media = new Media(); $media->setName('test.png'); $media->setProviderReference('ASDASDAS.png'); $media->setId(1023456); @@ -110,7 +108,7 @@ public function testThumbnail() $this->assertTrue($provider->requireThumbnails($media)); - $provider->addFormat('big', array('width' => 200, 'height' => 100,'constraint' => true)); + $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); $this->assertNotEmpty($provider->getFormats(), '::getFormats() return an array'); @@ -127,7 +125,7 @@ public function testEvent() $file = new \Symfony\Component\HttpFoundation\File\File(realpath(__DIR__.'/../fixtures/logo.png')); - $media = new Media; + $media = new Media(); $media->setBinaryContent($file); $media->setId(1023456); @@ -154,6 +152,6 @@ public function testTransformFormatNotSupported() $media->setBinaryContent($file); $this->assertNull($provider->transform($media)); - $this->assertNull($media->getWidth(), "Width staid null"); + $this->assertNull($media->getWidth(), 'Width staid null'); } } diff --git a/Tests/Provider/VimeoProviderTest.php b/Tests/Provider/VimeoProviderTest.php index 4b637dcbf..c0bb97554 100644 --- a/Tests/Provider/VimeoProviderTest.php +++ b/Tests/Provider/VimeoProviderTest.php @@ -11,12 +11,12 @@ namespace Sonata\MediaBundle\Tests\Provider; -use Sonata\MediaBundle\Tests\Entity\Media; -use Sonata\MediaBundle\Provider\VimeoProvider; -use Sonata\MediaBundle\Thumbnail\FormatThumbnail; use Buzz\Browser; use Buzz\Message\Response; use Imagine\Image\Box; +use Sonata\MediaBundle\Provider\VimeoProvider; +use Sonata\MediaBundle\Tests\Entity\Media; +use Sonata\MediaBundle\Thumbnail\FormatThumbnail; class VimeoProviderTest extends \PHPUnit_Framework_TestCase { @@ -54,7 +54,7 @@ public function testProvider() { $provider = $this->getProvider(); - $media = new Media; + $media = new Media(); $media->setName('Blinky™'); $media->setProviderName('vimeo'); $media->setProviderReference('21216091'); @@ -79,7 +79,7 @@ public function testThumbnail() $provider = $this->getProvider($browser); - $media = new Media; + $media = new Media(); $media->setName('Blinky™'); $media->setProviderName('vimeo'); $media->setProviderReference('21216091'); @@ -111,7 +111,7 @@ public function testTransformWithSig() $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); - $media = new Media; + $media = new Media(); $media->setBinaryContent('BDYAbAtaDzA'); $media->setId(1023456); @@ -135,7 +135,7 @@ public function testTransformWithUrl() $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); - $media = new Media; + $media = new Media(); $media->setBinaryContent('http://vimeo.com/012341231'); $media->setId(1023456); @@ -175,7 +175,7 @@ public function testHelperProperies() $provider = $this->getProvider(); $provider->addFormat('admin', array('width' => 100)); - $media = new Media; + $media = new Media(); $media->setName('Les tests'); $media->setProviderReference('ASDASDAS.png'); $media->setId(10); @@ -187,6 +187,5 @@ public function testHelperProperies() $this->assertInternalType('array', $properties); $this->assertEquals(100, $properties['height']); $this->assertEquals(100, $properties['width']); - } } diff --git a/Tests/Provider/YouTubeProviderTest.php b/Tests/Provider/YouTubeProviderTest.php index 31fdf802e..326bd70e6 100644 --- a/Tests/Provider/YouTubeProviderTest.php +++ b/Tests/Provider/YouTubeProviderTest.php @@ -11,14 +11,14 @@ namespace Sonata\MediaBundle\Tests\Provider; -use Sonata\MediaBundle\Tests\Entity\Media; -use Sonata\MediaBundle\Provider\YouTubeProvider; -use Sonata\MediaBundle\Thumbnail\FormatThumbnail; use Buzz\Browser; use Buzz\Message\Response; use Imagine\Image\Box; +use Sonata\MediaBundle\Provider\YouTubeProvider; +use Sonata\MediaBundle\Tests\Entity\Media; +use Sonata\MediaBundle\Thumbnail\FormatThumbnail; -class YoutubeProviderTest extends \PHPUnit_Framework_TestCase +class YouTubeProviderTest extends \PHPUnit_Framework_TestCase { public function getProvider(Browser $browser = null) { @@ -54,7 +54,7 @@ public function testProvider() { $provider = $this->getProvider(); - $media = new Media; + $media = new Media(); $media->setName('Nono le petit robot'); $media->setProviderName('youtube'); $media->setProviderReference('BDYAbAtaDzA'); @@ -80,7 +80,7 @@ public function testThumbnail() $provider = $this->getProvider($browser); - $media = new Media; + $media = new Media(); $media->setProviderName('youtube'); $media->setProviderReference('BDYAbAtaDzA'); $media->setContext('default'); @@ -111,7 +111,7 @@ public function testTransformWithSig() $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); - $media = new Media; + $media = new Media(); $media->setBinaryContent('BDYAbAtaDzA'); $media->setId(1023456); @@ -137,7 +137,7 @@ public function testTransformWithUrl($url) $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); - $media = new Media; + $media = new Media(); $media->setBinaryContent($url); $media->setId(1023456); @@ -148,7 +148,7 @@ public function testTransformWithUrl($url) $this->assertEquals('BDYAbAtaDzA', $media->getProviderReference(), '::getProviderReference() is set'); } - static function getUrls() + public static function getUrls() { return array( array('BDYAbAtaDzA'), @@ -189,7 +189,7 @@ public function testHelperProperties() $provider = $this->getProvider(); $provider->addFormat('admin', array('width' => 100)); - $media = new Media; + $media = new Media(); $media->setName('Les tests'); $media->setProviderReference('ASDASDAS.png'); $media->setId(10); diff --git a/Tests/Provider/phpSapiNameOverride.php b/Tests/Provider/phpSapiNameOverride.php index 64ffeb3b0..9005cb5b0 100644 --- a/Tests/Provider/phpSapiNameOverride.php +++ b/Tests/Provider/phpSapiNameOverride.php @@ -5,4 +5,4 @@ function php_sapi_name() { return 'foo'; -} \ No newline at end of file +} diff --git a/Tests/Resizer/SimpleResizerTest.php b/Tests/Resizer/SimpleResizerTest.php index a6b9bda35..3954df3d4 100644 --- a/Tests/Resizer/SimpleResizerTest.php +++ b/Tests/Resizer/SimpleResizerTest.php @@ -11,11 +11,11 @@ namespace Sonata\MediaBundle\Tests\Resizer; -use Sonata\MediaBundle\Resizer\SimpleResizer; -use Imagine\Image\Box; -use Gaufrette\File; use Gaufrette\Adapter\InMemory; +use Gaufrette\File; use Gaufrette\Filesystem; +use Imagine\Image\Box; +use Sonata\MediaBundle\Resizer\SimpleResizer; class SimpleResizerTest extends \PHPUnit_Framework_TestCase { @@ -35,7 +35,6 @@ public function testResizeWithNoWidth() public function testResize() { - $image = $this->getMock('Imagine\Image\ImageInterface'); $image->expects($this->once())->method('thumbnail')->will($this->returnValue($image)); $image->expects($this->once())->method('get')->will($this->returnValue(file_get_contents(__DIR__.'/../fixtures/logo.png'))); @@ -46,7 +45,7 @@ public function testResize() $media = $this->getMock('Sonata\MediaBundle\Model\MediaInterface'); $media->expects($this->exactly(2))->method('getBox')->will($this->returnValue(new Box(535, 132))); - $filesystem = new Filesystem(new InMemory); + $filesystem = new Filesystem(new InMemory()); $in = $filesystem->get('in', true); $in->setContent(file_get_contents(__DIR__.'/../fixtures/logo.png')); @@ -84,16 +83,16 @@ public function testGetBox($mode, $settings, Box $mediaSize, Box $result) public static function getBoxSettings() { return array( - array('inset', array( 'width' => 90, 'height' => 90 ), new Box(100, 120), new Box(75, 90)), - array('inset', array( 'width' => 90, 'height' => 90 ), new Box(50, 50), new Box(90, 90)), - array('inset', array( 'width' => 90, 'height' => null ), new Box(50, 50), new Box(90, 90)), - array('inset', array( 'width' => 90, 'height' => null ), new Box(567, 200), new Box(88, 31)), - array('inset', array( 'width' => 100, 'height' => 100 ), new Box(567, 200), new Box(100, 35)), - - array('outbound', array( 'width' => 90, 'height' => 90 ), new Box(100, 120), new Box(90, 108)), - array('outbound', array( 'width' => 90, 'height' => 90 ), new Box(50, 50), new Box(90, 90)), - array('outbound', array( 'width' => 90, 'height' => null ), new Box(50, 50), new Box(90, 90)), - array('outbound', array( 'width' => 90, 'height' => null ), new Box(567, 50), new Box(90, 8)), + array('inset', array('width' => 90, 'height' => 90), new Box(100, 120), new Box(75, 90)), + array('inset', array('width' => 90, 'height' => 90), new Box(50, 50), new Box(90, 90)), + array('inset', array('width' => 90, 'height' => null), new Box(50, 50), new Box(90, 90)), + array('inset', array('width' => 90, 'height' => null), new Box(567, 200), new Box(88, 31)), + array('inset', array('width' => 100, 'height' => 100), new Box(567, 200), new Box(100, 35)), + + array('outbound', array('width' => 90, 'height' => 90), new Box(100, 120), new Box(90, 108)), + array('outbound', array('width' => 90, 'height' => 90), new Box(50, 50), new Box(90, 90)), + array('outbound', array('width' => 90, 'height' => null), new Box(50, 50), new Box(90, 90)), + array('outbound', array('width' => 90, 'height' => null), new Box(567, 50), new Box(90, 8)), ); } } diff --git a/Tests/Resizer/SquareResizerTest.php b/Tests/Resizer/SquareResizerTest.php index c96c95ae0..a92f0d65a 100644 --- a/Tests/Resizer/SquareResizerTest.php +++ b/Tests/Resizer/SquareResizerTest.php @@ -11,11 +11,11 @@ namespace Sonata\MediaBundle\Tests\Resizer; -use Sonata\MediaBundle\Resizer\SquareResizer; -use Imagine\Image\Box; -use Gaufrette\File; use Gaufrette\Adapter\InMemory; +use Gaufrette\File; use Gaufrette\Filesystem; +use Imagine\Image\Box; +use Sonata\MediaBundle\Resizer\SquareResizer; class SquareResizerTest extends \PHPUnit_Framework_TestCase { @@ -81,10 +81,10 @@ public function testGetBox($settings, Box $mediaSize, Box $expected) public static function getBoxSettings() { return array( - array(array( 'width' => 90, 'height' => 90 ), new Box(100, 120), new Box(100, 100)), - array(array( 'width' => 90, 'height' => 90 ), new Box(50, 50), new Box(50, 50)), - array(array( 'width' => 90, 'height' => null ), new Box(50, 50), new Box(50, 50)), - array(array( 'width' => 90, 'height' => null ), new Box(567, 50), new Box(90, 7)), + array(array('width' => 90, 'height' => 90), new Box(100, 120), new Box(100, 100)), + array(array('width' => 90, 'height' => 90), new Box(50, 50), new Box(50, 50)), + array(array('width' => 90, 'height' => null), new Box(50, 50), new Box(50, 50)), + array(array('width' => 90, 'height' => null), new Box(567, 50), new Box(90, 7)), ); } } diff --git a/Tests/Security/RolesDownloadStrategyTest.php b/Tests/Security/RolesDownloadStrategyTest.php index 901e1c082..dc7ce6801 100644 --- a/Tests/Security/RolesDownloadStrategyTest.php +++ b/Tests/Security/RolesDownloadStrategyTest.php @@ -27,7 +27,7 @@ public function testIsGrantedTrue() $security->expects($this->any()) ->method('isGranted') - ->will($this->returnCallback(function(array $roles) { + ->will($this->returnCallback(function (array $roles) { return in_array('ROLE_ADMIN', $roles); })); $security->expects($this->once()) @@ -48,7 +48,7 @@ public function testIsGrantedFalse() $security->expects($this->any()) ->method('isGranted') - ->will($this->returnCallback(function(array $roles) { + ->will($this->returnCallback(function (array $roles) { return in_array('FOO', $roles); })); diff --git a/Tests/Thumbnail/FormatThumbnailTest.php b/Tests/Thumbnail/FormatThumbnailTest.php index 5db8cb2b4..841ea0d57 100644 --- a/Tests/Thumbnail/FormatThumbnailTest.php +++ b/Tests/Thumbnail/FormatThumbnailTest.php @@ -11,13 +11,10 @@ namespace Sonata\MediaBundle\Tests\Security; -use Sonata\MediaBundle\Thumbnail\FormatThumbnail; -use Sonata\MediaBundle\Provider\MediaProviderInterface; -use Sonata\MediaBundle\Model\MediaInterface; +use Gaufrette\Adapter\InMemory; use Gaufrette\File; use Gaufrette\Filesystem; -use Gaufrette\Adapter\InMemory; -use Sonata\MediaBundle\Resizer\ResizerInterface; +use Sonata\MediaBundle\Thumbnail\FormatThumbnail; class FormatThumbnailTest extends \PHPUnit_Framework_TestCase { @@ -29,8 +26,8 @@ public function testGenerate() $referenceFile = new File('myfile', $filesystem); $formats = array( - 'admin' => array('height' => 50, 'width' => 50, 'quality' => 100), - 'mycontext_medium' => array('height' => 500, 'width' => 500, 'quality' => 100), + 'admin' => array('height' => 50, 'width' => 50, 'quality' => 100), + 'mycontext_medium' => array('height' => 500, 'width' => 500, 'quality' => 100), 'anothercontext_large' => array('height' => 500, 'width' => 500, 'quality' => 100), ); diff --git a/Tests/Validator/Constraints/ValidMediaFormatTest.php b/Tests/Validator/Constraints/ValidMediaFormatTest.php index d1547322f..4e696ff03 100644 --- a/Tests/Validator/Constraints/ValidMediaFormatTest.php +++ b/Tests/Validator/Constraints/ValidMediaFormatTest.php @@ -15,7 +15,6 @@ class ValidMediaFormatTest extends \PHPUnit_Framework_TestCase { - public function testInstance() { $constraint = new ValidMediaFormat(); diff --git a/Tests/Validator/FormatValidatorTest.php b/Tests/Validator/FormatValidatorTest.php index faa90105d..1f68efa40 100644 --- a/Tests/Validator/FormatValidatorTest.php +++ b/Tests/Validator/FormatValidatorTest.php @@ -12,8 +12,8 @@ namespace Sonata\MediaBundle\Tests\Validator; use Sonata\MediaBundle\Provider\Pool; -use Sonata\MediaBundle\Validator\FormatValidator; use Sonata\MediaBundle\Validator\Constraints\ValidMediaFormat; +use Sonata\MediaBundle\Validator\FormatValidator; class FormatValidatorTest extends \PHPUnit_Framework_TestCase { @@ -35,7 +35,7 @@ public function testValidate() $validator = new FormatValidator($pool); $validator->initialize($context); - $validator->validate($gallery, new ValidMediaFormat); + $validator->validate($gallery, new ValidMediaFormat()); } public function testValidateWithValidContext() @@ -53,6 +53,6 @@ public function testValidateWithValidContext() $validator = new FormatValidator($pool); $validator->initialize($context); - $validator->validate($gallery, new ValidMediaFormat); + $validator->validate($gallery, new ValidMediaFormat()); } } diff --git a/Twig/Extension/FormatterMediaExtension.php b/Twig/Extension/FormatterMediaExtension.php index c271f09f5..c8db7a398 100644 --- a/Twig/Extension/FormatterMediaExtension.php +++ b/Twig/Extension/FormatterMediaExtension.php @@ -13,8 +13,8 @@ use Sonata\FormatterBundle\Extension\BaseProxyExtension; use Sonata\MediaBundle\Twig\TokenParser\MediaTokenParser; -use Sonata\MediaBundle\Twig\TokenParser\ThumbnailTokenParser; use Sonata\MediaBundle\Twig\TokenParser\PathTokenParser; +use Sonata\MediaBundle\Twig\TokenParser\ThumbnailTokenParser; class FormatterMediaExtension extends BaseProxyExtension { @@ -36,7 +36,7 @@ public function getAllowedTags() return array( 'media', 'path', - 'thumbnail' + 'thumbnail', ); } @@ -47,8 +47,8 @@ public function getAllowedMethods() { return array( 'Sonata\MediaBundle\Model\MediaInterface' => array( - 'getproviderreference' - ) + 'getproviderreference', + ), ); } @@ -81,9 +81,9 @@ public function getName() } /** - * @param integer $media - * @param string $format - * @param array $options + * @param int $media + * @param string $format + * @param array $options * * @return string */ @@ -93,9 +93,9 @@ public function media($media = null, $format, $options = array()) } /** - * @param integer $media - * @param string $format - * @param array $options + * @param int $media + * @param string $format + * @param array $options * * @return string */ @@ -105,8 +105,8 @@ public function thumbnail($media = null, $format, $options = array()) } /** - * @param integer $media - * @param string $format + * @param int $media + * @param string $format * * @return string */ diff --git a/Twig/Extension/MediaExtension.php b/Twig/Extension/MediaExtension.php index 9aa78f2e6..59ac4a20d 100644 --- a/Twig/Extension/MediaExtension.php +++ b/Twig/Extension/MediaExtension.php @@ -11,12 +11,12 @@ namespace Sonata\MediaBundle\Twig\Extension; -use Sonata\MediaBundle\Twig\TokenParser\MediaTokenParser; -use Sonata\MediaBundle\Twig\TokenParser\ThumbnailTokenParser; -use Sonata\MediaBundle\Twig\TokenParser\PathTokenParser; use Sonata\CoreBundle\Model\ManagerInterface; use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Provider\Pool; +use Sonata\MediaBundle\Twig\TokenParser\MediaTokenParser; +use Sonata\MediaBundle\Twig\TokenParser\PathTokenParser; +use Sonata\MediaBundle\Twig\TokenParser\ThumbnailTokenParser; class MediaExtension extends \Twig_Extension { @@ -105,7 +105,7 @@ private function getMedia($media) { if (!$media instanceof MediaInterface && strlen($media) > 0) { $media = $this->mediaManager->findOneBy(array( - 'id' => $media + 'id' => $media, )); } @@ -121,7 +121,7 @@ private function getMedia($media) } /** - * Returns the thumbnail for the provided media + * Returns the thumbnail for the provided media. * * @param \Sonata\MediaBundle\Model\MediaInterface $media * @param string $format @@ -191,7 +191,7 @@ public function path($media = null, $format) $media = $this->getMedia($media); if (!$media) { - return ''; + return ''; } $provider = $this->getMediaService() diff --git a/Twig/GlobalVariables.php b/Twig/GlobalVariables.php index 7ac367b64..a51009747 100644 --- a/Twig/GlobalVariables.php +++ b/Twig/GlobalVariables.php @@ -14,7 +14,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * GlobalVariables + * GlobalVariables. * * @author Thomas Rabaix */ diff --git a/Twig/Node/MediaNode.php b/Twig/Node/MediaNode.php index 513700e69..b92f136fb 100644 --- a/Twig/Node/MediaNode.php +++ b/Twig/Node/MediaNode.php @@ -27,7 +27,7 @@ public function __construct($extensionName, \Twig_Node_Expression $media, \Twig_ { $this->extensionName = $extensionName; - parent::__construct(array('media' => $media, 'format' => $format,'attributes' => $attributes), array(), $lineno, $tag); + parent::__construct(array('media' => $media, 'format' => $format, 'attributes' => $attributes), array(), $lineno, $tag); } /** diff --git a/Twig/Node/PathNode.php b/Twig/Node/PathNode.php index 3af77e434..cdbf8a2b7 100644 --- a/Twig/Node/PathNode.php +++ b/Twig/Node/PathNode.php @@ -19,7 +19,7 @@ class PathNode extends \Twig_Node * @param array $extensionName * @param \Twig_Node_Expression $media * @param \Twig_Node_Expression $format - * @param integer $lineno + * @param int $lineno * @param string $tag */ public function __construct($extensionName, \Twig_Node_Expression $media, \Twig_Node_Expression $format, $lineno, $tag = null) diff --git a/Twig/Node/ThumbnailNode.php b/Twig/Node/ThumbnailNode.php index 779363084..8d8975946 100644 --- a/Twig/Node/ThumbnailNode.php +++ b/Twig/Node/ThumbnailNode.php @@ -27,7 +27,7 @@ public function __construct($extensionName, \Twig_Node_Expression $media, \Twig_ { $this->extensionName = $extensionName; - parent::__construct(array('media' => $media, 'format' => $format,'attributes' => $attributes), array(), $lineno, $tag); + parent::__construct(array('media' => $media, 'format' => $format, 'attributes' => $attributes), array(), $lineno, $tag); } /** diff --git a/composer.json b/composer.json index add0a0c5e..5a661d22d 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,8 @@ "aws/aws-sdk-php": "~2.7", "doctrine/mongodb-odm": "~1.0", "jackalope/jackalope-doctrine-dbal": "~1.1", - "symfony/phpunit-bridge": "~2.7|~3.0" + "symfony/phpunit-bridge": "~2.7|~3.0", + "fabpot/php-cs-fixer": "~0.1|~1.0" }, "suggest": { "sonata-project/doctrine-orm-admin-bundle": "~2.3",