8000 Merge branch 'master' into form-phpdoc-2 · qcho/symfony@971aad0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 971aad0

Browse files
committed
Merge branch 'master' into form-phpdoc-2
2 parents 87a6fd0 + e81b88c commit 971aad0

File tree

101 files changed

+1550
-442
lines changed
  • src/Symfony
  • tests/Symfony/Tests
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    101 files changed

    +1550
    -442
    lines changed

    UPDATE.md

    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -139,6 +139,10 @@ beta1 to beta2
    139139

    140140
    * Serializer: The `$properties` argument has been dropped from all interfaces.
    141141

    142+
    * Form: Renamed option value "text" of "widget" option of the "date" type was
    143+
    renamed to "single-text". "text" indicates to use separate text boxes now
    144+
    (like for the "time" type).
    145+
    142146
    PR12 to beta1
    143147
    -------------
    144148

    src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -42,7 +42,6 @@ public function buildForm(FormBuilder $builder, array $options)
    4242
    public function getDefaultOptions(array $options)
    4343
    {
    4444
    $defaultOptions = array(
    45-
    'template' => 'choice',
    4645
    'multiple' => false,
    4746
    'expanded' => false,
    4847
    'em' => $this->em,

    src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -171,7 +171,7 @@ private function dumpAsset($name, OutputInterface $output)
    171171
    */
    172172
    private function doDump(AssetInterface $asset, OutputInterface $output)
    173173
    {
    174-
    $target = rtrim($this->basePath, '/').'/'.str_replace('_controller/', '', $asset->getTargetUrl());
    174+
    $target = rtrim($this->basePath, '/').'/'.str_replace('_controller/', '', $asset->getTargetPath());
    175175
    if (!is_dir($dir = dirname($target))) {
    176176
    $output->writeln('<info>[dir+]</info> '.$dir);
    177177
    if (false === @mkdir($dir, 0777, true)) {

    src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php

    Lines changed: 14 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -52,6 +52,19 @@ public function load(array $configs, ContainerBuilder $container)
    5252
    $container->setParameter('assetic.node.bin', $config['node']);
    5353
    $container->setParameter('assetic.sass.bin', $config['sass']);
    5454

    55+
    // register formulae
    56+
    $formulae = array();
    57+
    foreach ($config['assets'] as $name => $formula) {
    58+
    $formulae[$name] = array($formula['inputs'], $formula['filters'], $formula['options']);
    59+
    }
    60+
    61+
    if ($formulae) {
    62+
    $container->getDefinition('assetic.config_resource')->replaceArgument(0, $formulae);
    63+
    } else {
    64+
    $container->removeDefinition('assetic.config_loader');
    65+
    $container->removeDefinition('assetic.config_resource');
    66+
    }
    67+
    5568
    // register filters
    5669
    foreach ($config['filters'] as $name => $filter) {
    5770
    if (isset($filter['resource'])) {
    @@ -72,7 +85,7 @@ public function load(array $configs, ContainerBuilder $container)
    7285
    }
    7386

    7487
    // twig functions
    75-
    $container->getDefinition('assetic.twig_extension')->replaceArgument(2, $config['twig']['functions']);
    88+
    $container->setParameter('assetic.twig_extension.functions', $config['twig']['functions']);
    7689

    7790
    // choose dynamic or static
    7891
    if ($parameterBag->resolveValue($parameterBag->get('assetic.use_controller'))) {

    src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php

    Lines changed: 55 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -77,6 +77,61 @@ public function getConfigTreeBuilder()
    7777
    ->end()
    7878
    ->end()
    7979

    80+
    // assets
    81+
    ->fixXmlConfig('asset')
    82+
    ->children()
    83+
    ->arrayNode('assets')
    84+
    ->addDefaultsIfNotSet()
    85+
    ->requiresAtLeastOneElement()
    86+
    ->useAttributeAsKey('name')
    87+
    ->prototype('array')
    88+
    ->beforeNormalization()
    89+
    // a scalar is a simple formula of one input file
    90+
    ->ifTrue(function($v) { return !is_array($v); })
    91+
    ->then(function($v) { return array('inputs' => array($v)); })
    92+
    ->end()
    93+
    ->beforeNormalization()
    94+
    ->always()
    95+
    ->then(function($v)
    96+
    {
    97+
    // cast scalars as array
    98+
    foreach (array('input', 'inputs', 'filter', 'filters') as $key) {
    99+
    if (isset($v[$key]) && !is_array($v[$key])) {
    100+
    $v[$key] = array($v[$key]);
    101+
    }
    102+
    }
    103+
    104+
    // organize arbitrary options
    105+
    foreach ($v as $key => $value) {
    106+
    if (!in_array($key, array('input', 'inputs', 'filter', 'filters', 'option', 'options'))) {
    107+
    $v['options'][$key] = $value;
    108+
    unset($v[$key]);
    109+
    }
    110+
    }
    111+
    112+
    return $v;
    113+
    })
    114+
    ->end()
    115+
    116+
    // the formula
    117+
    ->fixXmlConfig('input')
    118+
    ->fixXmlConfig('filter')
    119+
    ->children()
    120+
    ->arrayNode('inputs')
    121+
    ->prototype('scalar')->end()
    122+
    ->end()
    123+
    ->arrayNode('filters')
    124+
    ->prototype('scalar')->end()
    125+
    ->end()
    126+
    ->arrayNode('options')
    127+
    ->useAttributeAsKey('name')
    128+
    ->prototype('variable')->end()
    129+
    ->end()
    130+
    ->end()
    131+
    ->end()
    132+
    ->end()
    133+
    ->end()
    134+
    80135
    // filters
    81136
    ->fixXmlConfig('filter')
    82137
    ->children()

    src/Symfony/Bundle/AsseticBundle/Factory/AssetFactory.php

    Lines changed: 43 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -12,6 +12,7 @@
    1212
    namespace Symfony\Bundle\AsseticBundle\Factory;
    1313

    1414
    use Assetic\Factory\AssetFactory as BaseAssetFactory;
    15+
    use Symfony\Component\DependencyInjection\ContainerInterface;
    1516
    use Symfony\Component\HttpKernel\KernelInterface;
    1617

    1718
    /**
    @@ -21,25 +22,43 @@
    2122
    */
    2223
    class AssetFactory extends BaseAssetFactory
    2324
    {
    24-
    protected $kernel;
    25+
    private $kernel;
    26+
    private $container;
    2527

    26-
    public function __construct(KernelInterface $kernel, $baseDir, $debug = false)
    28+
    /**
    29+
    * Constructor.
    30+
    *
    31+
    * @param KernelInterface $kernel The kernel is used to parse bundle notation
    32+
    * @param ContainerInterface $container The container is used to load the managers lazily, thus avoiding a circular dependency
    33+
    * @param string $baseDir The base directory for relative inputs
    34+
    * @param Boolean $debug The current debug mode
    35+
    */
    36+
    public function __construct(KernelInterface $kernel, ContainerInterface $container, $baseDir, $debug = false)
    2737
    {
    2838
    $this->kernel = $kernel;
    39+
    $this->container = $container;
    2940

    3041
    parent::__construct($baseDir, $debug);
    3142
    }
    3243

    3344
    /**
    34-
    * Adds support for bundle notation and globs.
    45+
    * Adds support for bundle notation file and glob assets.
    3546
    *
    36-
    * Please note this is a naive implementation of globs in that it doesn't
    47+
    * FIXME: This is a naive implementation of globs in that it doesn't
    3748
    * attempt to support bundle inheritance within the glob pattern itself.
    3849
    */
    39-
    protected function parseInput($input)
    50+
    protected function parseInput($input, array $options = array())
    4051
    {
    4152
    // expand bundle notation
    4253
    if ('@' == $input[0] && false !== strpos($input, '/')) {
    54+
    // use the bundle path as this asset's root
    55+
    $bundle = substr($input, 1);
    56+
    if (false !== $pos = strpos($bundle, '/')) {
    57+
    $bundle = substr($bundle, 0, $pos);
    58+
    }
    59+
    $options['root'] = array($this->kernel->getBundle($bundle)->getPath());
    60+
    61+
    // canonicalize the input
    4362
    if (false !== $pos = strpos($input, '*')) {
    4463
    // locateResource() does not support globs so we provide a naive implementation here
    4564
    list($before, $after) = explode('*', $input, 2);
    @@ -49,6 +68,24 @@ protected function parseInput($input)
    4968
    }
    5069
    }
    5170

    52-
    return parent::parseInput($input);
    71+
    return parent::parseInput($input, $options);
    72+
    }
    73+
    74+
    protected function createAssetReference($name)
    75+
    {
    76+
    if (!$this->getAssetManager()) {
    77+
    $this->setAssetManager($this->container->get('assetic.asset_manager'));
    78+
    }
    79+
    80+
    return parent::createAssetReference($name);
    81+
    }
    82+
    83+
    protected function getFilter($name)
    84+
    {
    85+
    if (!$this->getFilterManager()) {
    86+
    $this->setFilterManager($this->container->get('assetic.filter_manager'));
    87+
    }
    88+
    89+
    return parent::getFilter($name);
    5390
    }
    5491
    }
    Lines changed: 29 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,29 @@
    1+
    <?php
    2+
    3+
    /*
    4+
    * This file is part of the Symfony framework.
    5+
    *
    6+
    * (c) Fabien Potencier <fabien@symfony.com>
    7+
    *
    8+
    * This source file is subject to the MIT license that is bundled
    9+
    * with this source code in the file LICENSE.
    10+
    */
    11+
    12+
    namespace Symfony\Bundle\AsseticBundle\Factory\Loader;
    13+
    14+
    use Assetic\Factory\Loader\FormulaLoaderInterface;
    15+
    use Assetic\Factory\Resource\ResourceInterface;
    16+
    use Symfony\Bundle\AsseticBundle\Factory\ConfigurationResource;
    17+
    18+
    /**
    19+
    * Loads configured formulae.
    20+
    *
    21+
    * @author Kris Wallsmith <kris@symfony.com>
    22+
    */
    23+
    class ConfigurationLoader implements FormulaLoaderInterface
    24+
    {
    25+
    public function load(ResourceInterface $resource)
    26+
    {
    27+
    return $resource instanceof ConfigurationResource ? $resource->getContent() : array();
    28+
    }
    29+
    }
    Lines changed: 44 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,44 @@
    1+
    <?php
    2+
    3+
    /*
    4+
    * This file is part of the Symfony framework.
    5+
    *
    6+
    * (c) Fabien Potencier <fabien@symfony.com>
    7+
    *
    8+
    * This source file is subject to the MIT license that is bundled
    9+
    * with this source code in the file LICENSE.
    10+
    */
    11+
    12+
    namespace Symfony\Bundle\AsseticBundle\Factory\Resource;
    13+
    14+
    use Assetic\Factory\Resource\ResourceInterface;
    15+
    16+
    /**
    17+
    * A configured resource.
    18+
    *
    19+
    * @author Kris Wallsmith <kris@symfony.com>
    20+
    */
    21+
    class ConfigurationResource implements ResourceInterface
    22+
    {
    23+
    private $formulae;
    24+
    25+
    public function __construct(array $formulae)
    26+
    {
    27+
    $this->formulae = $formulae;
    28+
    }
    29+
    30+
    public function isFresh($timestamp)
    31+
    {
    32+
    return true;
    33+
    }
    34+
    35+
    public function getContent()
    36+
    {
    37+
    return $this->formulae;
    38+
    }
    39+
    40+
    public function __toString()
    41+
    {
    42+
    return 'symfony';
    43+
    }
    44+
    }

    src/Symfony/Bundle/AsseticBundle/Factory/Worker/UseControllerWorker.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -23,9 +23,9 @@ class UseControllerWorker implements WorkerInterface
    2323
    {
    2424
    public function process(AssetInterface $asset)
    2525
    {
    26-
    $targetUrl = $asset->getTargetUrl();
    26+
    $targetUrl = $asset->getTargetPath();
    2727
    if ($targetUrl && '/' != $targetUrl[0] && 0 !== strpos($targetUrl, '_controller/')) {
    28-
    $asset->setTargetUrl('_controller/'.$targetUrl);
    28+
    $asset->setTargetPath('_controller/'.$targetUrl);
    2929
    }
    3030

    3131
    return $asset;

    src/Symfony/Bundle/AsseticBundle/Resources/config/assetic.xml

    Lines changed: 11 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -10,6 +10,8 @@
    1010
    <parameter key="assetic.asset_manager_cache_warmer.class">Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer</parameter>
    1111
    <parameter key="assetic.cached_formula_loader.class">Assetic\Factory\Loader\CachedFormulaLoader</parameter>
    1212
    <parameter key="assetic.config_cache.class">Assetic\Cache\ConfigCache</parameter>
    13+
    <parameter key="assetic.config_loader.class">Symfony\Bundle\AsseticBundle\Factory\Loader\ConfigurationLoader</parameter>
    14+
    <parameter key="assetic.config_resource.class">Symfony\Bundle\AsseticBundle\Factory\Resource\ConfigurationResource</parameter>
    1315
    <parameter key="assetic.coalescing_directory_resource.class">Assetic\Factory\Resource\CoalescingDirectoryResource</parameter>
    1416
    <parameter key="assetic.directory_resource.class">Symfony\Bundle\AsseticBundle\Factory\Resource\DirectoryResource</parameter>
    1517
    <parameter key="assetic.filter_manager.class">Symfony\Bundle\AsseticBundle\FilterManager</parameter>
    @@ -31,9 +33,17 @@
    3133

    3234
    <service id="assetic.asset_factory" class="%assetic.asset_factory.class%" public="false">
    3335
    <argument type="service" id="kernel" />
    36+
    <argument type="service" id="service_container" />
    3437
    <argument>%assetic.read_from%</argument>
    3538
    <argument>%assetic.debug%</argument>
    36-
    <call method="setFilterManager"><argument type="service" id="assetic.filter_manager" /></call>
    39+
    </service>
    40+
    41+
    <service id="assetic.config_loader" class="%assetic.config_loader.class%" public="false">
    42+
    <tag name="assetic.formula_loader" alias="config" />
    43+
    </service>
    44+
    <service id="assetic.config_resource" class="%assetic.config_resource.class%" public="false">
    45+
    <tag name="assetic.formula_resource" loader="config" />
    46+
    <argument type="collection" /> <!-- configured formulae -->
    3747
    </service>
    3848

    3949
    <service id="assetic.config_cache" class="%assetic.config_cache.class%" public="false">

    0 commit comments

    Comments
     (0)
    0