Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed Oct 19, 2017
2 parents 6139675 + ce9d49f commit 9e7f318
Show file tree
Hide file tree
Showing 70 changed files with 504 additions and 509 deletions.
2 changes: 0 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
-->
I am targeting this branch, because {reason}.

In case of bug fix, `3.x` **MUST** be targeted.

<!--
Specify which issues will be fixed/closed.
Remove it if this is not related.
Expand Down
3 changes: 1 addition & 2 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
preset: symfony

enabled:
- class_keyword_remove
- combine_consecutive_unsets
- long_array_syntax
- short_array_syntax
- newline_after_open_tag
- no_php4_constructor
- no_useless_else
Expand Down
4 changes: 2 additions & 2 deletions Annotation/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function processMetadata(ClassMetadata $metadata)
$metadata->id = $this->id;
}

$metadata->tags['sonata.block'][] = array();
$metadata->arguments = array($this->id, new Reference('templating'));
$metadata->tags['sonata.block'][] = [];
$metadata->arguments = [$this->id, new Reference('templating')];
}
}
2 changes: 1 addition & 1 deletion Block/BlockContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BlockContext implements BlockContextInterface
* @param BlockInterface $block
* @param array $settings
*/
public function __construct(BlockInterface $block, array $settings = array())
public function __construct(BlockInterface $block, array $settings = [])
{
$this->block = $block;
$this->settings = $settings;
Expand Down
26 changes: 13 additions & 13 deletions Block/BlockContextManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class BlockContextManager implements BlockContextManagerInterface
* @param LoggerInterface|null $logger
*/
public function __construct(BlockLoaderInterface $blockLoader, BlockServiceManagerInterface $blockService,
array $cacheBlocks = array(), LoggerInterface $logger = null
array $cacheBlocks = [], LoggerInterface $logger = null
) {
$this->blockLoader = $blockLoader;
$this->blockService = $blockService;
Expand All @@ -69,7 +69,7 @@ public function __construct(BlockLoaderInterface $blockLoader, BlockServiceManag
*/
public function addSettingsByType($type, array $settings, $replace = false)
{
$typeSettings = isset($this->settingsByType[$type]) ? $this->settingsByType[$type] : array();
$typeSettings = isset($this->settingsByType[$type]) ? $this->settingsByType[$type] : [];
if ($replace) {
$this->settingsByType[$type] = array_merge($typeSettings, $settings);
} else {
Expand All @@ -82,7 +82,7 @@ public function addSettingsByType($type, array $settings, $replace = false)
*/
public function addSettingsByClass($class, array $settings, $replace = false)
{
$classSettings = isset($this->settingsByClass[$class]) ? $this->settingsByClass[$class] : array();
$classSettings = isset($this->settingsByClass[$class]) ? $this->settingsByClass[$class] : [];
if ($replace) {
$this->settingsByClass[$class] = array_merge($classSettings, $settings);
} else {
Expand All @@ -105,7 +105,7 @@ public function exists($type)
/**
* {@inheritdoc}
*/
public function get($meta, array $settings = array())
public function get($meta, array $settings = [])
{
if (!$meta instanceof BlockInterface) {
$block = $this->blockLoader->load($meta);
Expand Down Expand Up @@ -148,25 +148,25 @@ public function get($meta, array $settings = array())
protected function configureSettings(OptionsResolver $optionsResolver, BlockInterface $block)
{
// defaults for all blocks
$optionsResolver->setDefaults(array(
$optionsResolver->setDefaults([
'use_cache' => true,
'extra_cache_keys' => array(),
'attr' => array(),
'extra_cache_keys' => [],
'attr' => [],
'template' => false,
'ttl' => (int) $block->getTtl(),
));
]);

$optionsResolver
->addAllowedTypes('use_cache', 'bool')
->addAllowedTypes('extra_cache_keys', 'array')
->addAllowedTypes('attr', 'array')
->addAllowedTypes('ttl', 'int')
->addAllowedTypes('template', array('string', 'bool'));
->addAllowedTypes('template', ['string', 'bool']);

// add type and class settings for block
$class = ClassUtils::getClass($block);
$settingsByType = isset($this->settingsByType[$block->getType()]) ? $this->settingsByType[$block->getType()] : array();
$settingsByClass = isset($this->settingsByClass[$class]) ? $this->settingsByClass[$class] : array();
$settingsByType = isset($this->settingsByType[$block->getType()]) ? $this->settingsByType[$block->getType()] : [];
$settingsByClass = isset($this->settingsByClass[$class]) ? $this->settingsByClass[$class] : [];
$optionsResolver->setDefaults(array_merge($settingsByType, $settingsByClass));
}

Expand Down Expand Up @@ -241,10 +241,10 @@ private function resolve(BlockInterface $block, $settings)
$isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Sonata\BlockBundle\Block\AbstractBlockService';
}

$this->reflectionCache[$serviceClass] = array(
$this->reflectionCache[$serviceClass] = [
'isOldOverwritten' => $isOldOverwritten,
'isNewOverwritten' => $isNewOverwritten,
);
];
}

if ($this->reflectionCache[$serviceClass]['isOldOverwritten'] && !$this->reflectionCache[$serviceClass]['isNewOverwritten']) {
Expand Down
2 changes: 1 addition & 1 deletion Block/BlockContextManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ public function addSettingsByClass($class, array $settings, $replace = false);
*
* @throws BlockOptionsException
*/
public function get($meta, array $settings = array());
public function get($meta, array $settings = []);
}
12 changes: 6 additions & 6 deletions Block/BlockServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class BlockServiceManager implements BlockServiceManagerInterface
*/
public function __construct(ContainerInterface $container, $debug, LoggerInterface $logger = null)
{
$this->services = array();
$this->contexts = array();
$this->services = [];
$this->contexts = [];
$this->container = $container;
}

Expand Down Expand Up @@ -79,13 +79,13 @@ public function has($id)
/**
* {@inheritdoc}
*/
public function add($name, $service, $contexts = array())
public function add($name, $service, $contexts = [])
{
$this->services[$name] = $service;

foreach ($contexts as $context) {
if (!array_key_exists($context, $this->contexts)) {
$this->contexts[$context] = array();
$this->contexts[$context] = [];
}

$this->contexts[$context][] = $name;
Expand All @@ -112,10 +112,10 @@ public function getServices()
public function getServicesByContext($context, $includeContainers = true)
{
if (!array_key_exists($context, $this->contexts)) {
return array();
return [];
}

$services = array();
$services = [];

$containers = $this->container->getParameter('sonata.block.container.types');

Expand Down
2 changes: 1 addition & 1 deletion Block/BlockServiceManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface BlockServiceManagerInterface
* @param string $service
* @param array $contexts
*/
public function add($name, $service, $contexts = array());
public function add($name, $service, $contexts = []);

/**
* Return the block service linked to the link.
Expand Down
2 changes: 1 addition & 1 deletion Block/Loader/ServiceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function load($configuration)
$block->setEnabled(true);
$block->setCreatedAt(new \DateTime());
$block->setUpdatedAt(new \DateTime());
$block->setSettings(isset($configuration['settings']) ? $configuration['settings'] : array());
$block->setSettings(isset($configuration['settings']) ? $configuration['settings'] : []);

return $block;
}
Expand Down
2 changes: 1 addition & 1 deletion Block/Service/AbstractAdminBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ public function validateBlock(ErrorElement $errorElement, BlockInterface $block)
*/
public function getBlockMetadata($code = null)
{
return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataBlockBundle', array('class' => 'fa fa-file'));
return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataBlockBundle', ['class' => 'fa fa-file']);
}
}
16 changes: 8 additions & 8 deletions Block/Service/AbstractBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct($name = null, EngineInterface $templating = null)
*
* @return Response
*/
public function renderResponse($view, array $parameters = array(), Response $response = null)
public function renderResponse($view, array $parameters = [], Response $response = null)
{
return $this->getTemplating()->renderResponse($view, $parameters, $response);
}
Expand All @@ -74,7 +74,7 @@ public function renderResponse($view, array $parameters = array(), Response $res
*
* @return Response
*/
public function renderPrivateResponse($view, array $parameters = array(), Response $response = null)
public function renderPrivateResponse($view, array $parameters = [], Response $response = null)
{
return $this->renderResponse($view, $parameters, $response)
->setTtl(0)
Expand Down Expand Up @@ -104,10 +104,10 @@ public function configureSettings(OptionsResolver $resolver)
*/
public function getCacheKeys(BlockInterface $block)
{
return array(
return [
'block_id' => $block->getId(),
'updated_at' => $block->getUpdatedAt() ? $block->getUpdatedAt()->format('U') : strtotime('now'),
);
];
}

/**
Expand All @@ -122,26 +122,26 @@ public function load(BlockInterface $block)
*/
public function getJavascripts($media)
{
return array();
return [];
}

/**
* {@inheritdoc}
*/
public function getStylesheets($media)
{
return array();
return [];
}

/**
* {@inheritdoc}
*/
public function execute(BlockContextInterface $blockContext, Response $response = null)
{
return $this->renderResponse($blockContext->getTemplate(), array(
return $this->renderResponse($blockContext->getTemplate(), [
'block_context' => $blockContext,
'block' => $blockContext->getBlock(),
), $response);
], $response);
}

/**
Expand Down
38 changes: 19 additions & 19 deletions Block/Service/ContainerBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,56 +32,56 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
{
$formMapper->add('enabled');

$formMapper->add('settings', 'sonata_type_immutable_array', array(
'keys' => array(
array('code', 'text', array('required' => false)),
array('layout', 'textarea', array()),
array('class', 'text', array('required' => false)),
array('template', 'sonata_type_container_template_choice', array()),
),
));
$formMapper->add('settings', 'sonata_type_immutable_array', [
'keys' => [
['code', 'text', ['required' => false]],
['layout', 'textarea', []],
['class', 'text', ['required' => false]],
['template', 'sonata_type_container_template_choice', []],
],
]);

$formMapper->add('children', 'sonata_type_collection', array(), array(
$formMapper->add('children', 'sonata_type_collection', [], [
'admin_code' => 'sonata.page.admin.block',
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position',
));
]);
}

/**
* {@inheritdoc}
*/
public function execute(BlockContextInterface $blockContext, Response $response = null)
{
return $this->renderResponse($blockContext->getTemplate(), array(
return $this->renderResponse($blockContext->getTemplate(), [
'block' => $blockContext->getBlock(),
'decorator' => $this->getDecorator($blockContext->getSetting('layout')),
'settings' => $blockContext->getSettings(),
), $response);
], $response);
}

/**
* {@inheritdoc}
*/
public function configureSettings(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'code' => '',
'layout' => '{{ CONTENT }}',
'class' => '',
'template' => 'SonataBlockBundle:Block:block_container.html.twig',
));
]);
}

/**
* {@inheritdoc}
*/
public function getBlockMetadata($code = null)
{
return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataBlockBundle', array(
return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataBlockBundle', [
'class' => 'fa fa-square-o',
));
]);
}

/**
Expand All @@ -95,14 +95,14 @@ protected function getDecorator($layout)
{
$key = '{{ CONTENT }}';
if (strpos($layout, $key) === false) {
return array();
return [];
}

$segments = explode($key, $layout);
$decorator = array(
$decorator = [
'pre' => isset($segments[0]) ? $segments[0] : '',
'post' => isset($segments[1]) ? $segments[1] : '',
);
];

return $decorator;
}
Expand Down
Loading

0 comments on commit 9e7f318

Please sign in to comment.