Git Product home page Git Product logo

jmsdiextrabundle's Introduction

jmsdiextrabundle's People

Contributors

adrienbrault avatar akcoder avatar bgaleotti avatar bronze1man avatar chosroes avatar dennisoehme avatar fabpot avatar greg0ire avatar gremo avatar guilhemn avatar jean85 avatar kriswallsmith avatar lemoinem avatar ma27 avatar matejvelikonja avatar mplx avatar mrardon avatar nyholm avatar pdias avatar pink6440 avatar ruudk avatar sam0delkin avatar schmittjoh avatar sescandell avatar taylankasap avatar valiodotch avatar vicb avatar vladar avatar wodka avatar zerkalica avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jmsdiextrabundle's Issues

@DI\LookupMethod does not work on my non-controller service

My service looks like this and is defined in services.xml

<?php

namespace Jbi\CoreBundle\Persistence\Doctrine\Service;

use Jbi\Domain\Service\ArticlesServiceInterface;
use Jbi\Domain\Entity\ArticleInterface;

use JMS\DiExtraBundle\Annotation as DI;

/**
 *
 */
class ArticlesService implements ArticlesServiceInterface
{
    /**
     * {@inheritdoc} 
     */
    public function createArticle(ArticleInterface $article)
    {
        $em = $this->getEntityManager();

        $em->persist($article);
        $em->flush();
    }

    /**
     * @DI\LookupMethod("doctrine.orm.entity_manager")
     *
     * @return ObjectManager
     */
    public function getEntityManager()
    {
    }
}

That will give an error in createArticle with Fatal error: Call to a member function persist() on a non-object in ... - do you know why JMS Di Extra doesn't take care of this? I can see the generated metadata cache file, but it doesn't intercept it.

FYI, I want to configure this service in services.xml with the intention that at any point I could swap the class Jbi\CoreBundle\Persistence\Doctrine\Service for, say, Jbi\CoreBundle\Persistence\Propel\Service or Jbi\CoreBundle\Persistence\DynamoDB\Service

grep: add handling of no files :)

Following error appears when no files are found

Command "/bin/grep --fixed-strings --directories=recurse --devices=skip --files-with-matches --with-filename --max-count=1 --color=never --exclude-dir=\.git --exclude-dir=Resources --exclude-dir=Tests --exclude-dir=Controller --include=*.php 'JMS\DiExtraBundle\Annotation' '..../app/../src'" exited with non-successful status code "1".

fatal error on reusable bundles with optional dependencies

we run into a problem when the DI extra bundle is used together with the cmf bundles that optionally provide controllers for sonata admin. we don't use DI for routing and we do not load the controller services if sonata is not available, but the cache:warmup tries to load all controllers and triggers a fatal error because of the missing sonata class. this produces the following stack trace:

symfony-cmf/simple-cms-bundle#16 (comment)

is there a way the DI extra bundle can avoid this error? or should we place those controllers in a different namespace than /Controller? does the ControllerInjectorsWarmer only scan that directory for controllers? i think we could move them as they are only used as services anyways.

Controllers cannot guess templates after enabling JMSDiExtra bundle

Hi Johannes, after enabling JMSDiExtraBundle in my application, my controllers no longer work. I am receiving the following error:

The "Jbi\ProjectBundle\Controller\ProjectController__CG__b0488524c7d97e7f63deb8ebce2e1d41fb1363a8" class does not look like a controller class (it must be in a "Controller" sub-namespace and the class name must end with "Controller")

It seems obvious that a custom class has been generated and now the Symfony template handler cannot figure out where my templates are located (FYI, I'm using the @Template annotation for most actions).

Please let me know what you think and if you need any more information.

Cheers,
Jon

Issue with Symfony 2.1 SE master

Hi,

When I clone a new Symfony 2.1 SE master project and try to install the dependencies using Composer I get this error:

composer install
Loading composer repositories with package information
Installing dependencies from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for jms/di-extra-bundle == 1.1.9999999.9999999-dev -> satisfiable by jms/di-extra-bundle 1.1.x-dev.
    - Can only install one of: jms/di-extra-bundle 1.2.x-dev, jms/di-extra-bundle 1.1.x-dev.
    - Installation request for jms/di-extra-bundle == 1.2.9999999.9999999-dev -> satisfiable by jms/di-extra-bundle 1.2.x-dev.

Cache Problem (timeout) in dev-enviroment

There is currently a problem with the Cache and JMSDiExtraBundle in dev enviroment, like it had been with the basic annotations in symfony2 RC5.

Without running "cache:clear" after file changes i only get timouts like this:

Fatal error: Maximum execution time of 60 seconds exceeded in [...]/vendor/doctrine-common/lib/Doctrine/Common/Annotations/PhpParser.php on line 137

Bug: Inconsistent newlines

These files have inconsistent newlines (CRLF+LF):

Tests/Finder/FindstrPatternFinderTest.php
Tests/Finder/GrepPatternFinderTest.php
Tests/Finder/PhpPatternFinderTest.php
Tests/Fixture/NonEmptyDirectory/Service1.php
Tests/Fixture/NonEmptyDirectory/SubDir1/Service2.php
Tests/Fixture/NonEmptyDirectory/SubDir2/Service3.php

Please fix it.

The annotation @Orm\Entity was never imported in controller class

Env:
Symfony 2.0
Doctrine 2.1.6
PHP 5.3.3
APC 3.1.9
env=dev, debug=true

There is controller with one action

class SocialServiceController extends Controller
{
    public function disconnectSocialServiceAction()
    {
                var_dump(1);
        if (!$this->getSecurityContext()->isGranted('ROLE_USER')) {
            var_dump(2);
        }
     }
}

This controller hasn't any docblock so much the entity. In real entity User Orm annotation imported. It works correctly when apc is disabled. We have enabled apc in prod and cann't deploy new update ;(.

Trace screen http://easycaptures.com/fs/uploaded/480/6249496393.png

Update the Documentation / Best practice?

Sorry to bother you again, but i have some questions on the documentation this time..
First of all, thanks for this great bundle. It makes Service-creation and Injection much better with reducing the configuration files.

1.] What is the intended useage / the best practices?

use JMS\DiExtraBundle\Annotation as DI;

/** 
 * @DI\Inject([...])
 */

like the Symfony-ORM way for entities.

Or should i use:

use JMS\DiExtraBundle\Annotation\Inject;

/** 
 * @Inject([...])
 */

Both methods are shown in the documentation. I think it's better to define one as the prefered / recommended.
My personal preference would be the "simple" @Inject, @service, ... Annotations.

2.] Is the Documentation up to date or are these bugs?

a)
Quote: "Note that you cannot use the @Inject annotation on private, or protected properties. Likewise, the @InjectParams annotation does not work on protected, or private methods."

/**
 * @Inject("security.context", required = false)
 */
private $securityContext;

Ok, this only works in controllers, but i think the private-Definition should only be used in the special Controller-Section of the documentation and not in the "general one": Annotations -> @Inject.

/**
 * @Inject("security.context", required = false)
 */
public $securityContext;

What does the "required = false" do?

b)

/** @DI\LookupMethod("mailer") */
abstract protected function getMailer();

Fatal error: Abstract function ... cannot contain body in [...]

this works:

/**
 * @LookupMethod("mailer")
 */
protected function getMailer() {}

c)

/**
 * @Service
 */
class Listener
{
    /**
     * @InjectParams({
     *     "em" = @Inject("doctrine.entity_manager")
     * })
     */
    public function __construct(EntityManager $em, Session $session)
    {
        // ...
    }
}

Doesn't work within a Service.
RuntimeException: Invalid argument key "em" found.

Make possible to @Inject private properties

Heelo,
Is there any way we couls make the @Inject annotations useable on a non-controller class
as is
or maybe by making the class follow some conventions such as having a corresponding setter Method that would automatically be called to inject the object.

Mountain Lion, Grep & Max-count=1

Hi,

I've just discovered a really really strange bug after upgrading my MBP to Mountain Lion. It seems that "grep" version has change since Lion and especially the "max-count" option. While in Lion, "max-count=NUM" was meaning "stop reading a file after NUM match(es) in the file", in Mountain Lion, it seems to mean "stop reading input after NUM file(s) matching criterias".
And since DiExtraBundle is using grep to find all files (in JMS\DiExtraBundle\Finder\PatternFinder) that need to be processed, it stops after the first file.

Examples on Mountain Lion :

=> max-count=1
MacBook-Pro-de-Remi:publicWebsite remi$ /usr/bin/grep --fixed-strings --directories=recurse --devices=skip --files-with-matches --with-filename --max-count=1 --color=never --include=*.php 'JMS\DiExtraBundle\Annotation' '/Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle' /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/ContentProvider.php

=> max-count=5
MacBook-Pro-de-Remi:publicWebsite remi$ /usr/bin/grep --fixed-strings --directories=recurse --devices=skip --files-with-matches --with-filename --max-count=5 --color=never --include=*.php 'JMS\DiExtraBundle\Annotation' '/Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle' /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/ContentProvider.php /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/OfferProvider.php /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/OffersProvider.php /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/StoreProvider.php /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/StoresProvider.php

=> without max-count
MacBook-Pro-de-Remi:publicWebsite remi$ /usr/bin/grep --fixed-strings --directories=recurse --devices=skip --files-with-matches --with-filename --color=never --include=*.php 'JMS\DiExtraBundle\Annotation' '/Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle' /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/ContentProvider.php /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/OfferProvider.php /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/OffersProvider.php /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/StoreProvider.php /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/StoresProvider.php /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/SurtaxedPhoneNumberProvider.php /Users/remi/dev/sa/publicWebsite/vendor/bundles/Kbrw/SA/Bundles/ResponseBundle/Provider/TreeProvider.php

I'm trying to install the gnu grep version using macport to fix it but I think that removing "max-count" from the command-line should be a good option. What do you think ?

Solaris grep issues

I am not sure if we should consider this as a bug, but i like to report it for completeness:
I get a error on a solaris machine when enabling the translation:

 PHP Fatal error:  Uncaught exception 'JMS\\DiExtraBundle\\Exception\\RuntimeException' with message 'Command "/usr/bin/grep --extended-regexp --directories=recurse --devices=skip --files-with-matches --with-filename --color=never --include=*.php '.*'
...
/usr/bin/grep: Unzulรคssige Option -- extended-regexp
/usr/bin/grep: Unzulรคssige Option -- directories=recurse
/usr/bin/grep: Unzulรคssige Option -- devices=skip
/usr/bin/grep: Unzulรคssige Option -- files-with-matches
/usr/bin/grep: Unzulรคssige Option -- with-filename
/usr/bin/grep: Unzulรคssige Option -- color=never
/usr/bin/grep: Unzulรคssige Option -- include=*.php
...

this is probably due to a "bad" grep version on this solaris or a wrong grep path.

any ideas on that issue?
and also how could i change the path to grep?
i found the const as private.

@Inject does not work for non-controller classes without @Service

Has it to be clarified in the documentation or is it an issue?

@Inject does not work for non-controller classes without @service annotation for class.

Usage @Inject with @service creates some service definition, that overrides the entries in system.yml. This would be not the big trouble, but some features of system.yml are missed in the JMSDIExtraBundle (like call of methods).

P.S. Anyway great bundle :)

Doesn't install with symfony 2.2.*

Hello.
I tried to update composer.json for using symfony 2.2.* but jms/di-extra-bundle requires Symfoy/finder 2.1.*

error:
Loading composer repositories with package information
Installing dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for symfony/symfony 2.2.* -> satisfiable by symfony/symfony 2.2.x-dev.
- jms/di-extra-bundle dev-master requires symfony/finder 2.1.* -> satisfiable by symfony/finder v2.1.0, symfony/finder v2.1.0-RC2, symfony/finder v2.1.1, symfony/symfony v2.1.0-RC1, symfony/symfony v2.1.0-RC2, symfony/finder v2.1.0-BETA2, symfony/finder v2.1.0-BETA3, symfony/finder v2.1.0-BETA4, symfony/finder v2.1.0-RC1, symfony/symfony v2.1.0-BETA2, symfony/symfony v2.1.0-BETA3, symfony/symfony v2.1.0-BETA4, symfony/symfony 2.1.x-dev, symfony/symfony v2.1.0, symfony/symfony v2.1.1, symfony/finder v2.1.0-BETA1, symfony/symfony v2.1.0-BETA1, symfony/finder 2.1.x-dev.
- Can only install one of: symfony/symfony 2.2.x-dev, symfony/symfony v2.1.0-RC1.
- Can only install one of: symfony/symfony 2.2.x-dev, symfony/symfony v2.1.0-RC2.
- Can only install one of: symfony/symfony 2.2.x-dev, symfony/symfony v2.1.0-BETA2.
- Can only install one of: symfony/symfony 2.2.x-dev, symfony/symfony v2.1.0-BETA3.
- Can only install one of: symfony/symfony 2.2.x-dev, symfony/symfony v2.1.0-BETA4.
- Can only install one of: symfony/symfony 2.2.x-dev, symfony/symfony 2.1.x-dev.
- Can only install one of: symfony/symfony v2.1.0, symfony/symfony 2.2.x-dev.
- Can only install one of: symfony/symfony v2.1.1, symfony/symfony 2.2.x-dev.
- Can only install one of: symfony/symfony v2.1.0-BETA1, symfony/symfony 2.2.x-dev.
- don't install symfony/symfony 2.2.x-dev|don't install symfony/finder v2.1.0
- don't install symfony/symfony 2.2.x-dev|don't install symfony/finder v2.1.0-RC2
- don't install symfony/symfony 2.2.x-dev|don't install symfony/finder v2.1.1
- don't install symfony/symfony 2.2.x-dev|don't install symfony/finder v2.1.0-BETA2
- don't install symfony/symfony 2.2.x-dev|don't install symfony/finder v2.1.0-BETA3
- don't install symfony/symfony 2.2.x-dev|don't install symfony/finder v2.1.0-BETA4
- don't install symfony/symfony 2.2.x-dev|don't install symfony/finder v2.1.0-RC1
- don't install symfony/finder v2.1.0-BETA1|don't install symfony/symfony 2.2.x-dev
- don't install symfony/finder 2.1.x-dev|don't install symfony/symfony 2.2.x-dev
- Installation request for jms/di-extra-bundle dev-master -> satisfiable by jms/di-extra-bundle dev-master.

composer.json:
{
"name": "symfony/framework-standard-edition",
"description": "The "Symfony Standard Edition" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.2.",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.0.
",
"twig/extensions": "1.0.",
"symfony/assetic-bundle": "2.1.
",
"symfony/swiftmailer-bundle": "2.1.",
"symfony/monolog-bundle": "2.1.
",
"sensio/distribution-bundle": "2.2.",
"sensio/framework-extra-bundle": "2.2.
",
"sensio/generator-bundle": "2.1.",
"jms/security-extra-bundle": "1.2.
",
"jms/di-extra-bundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web"
}
}

Refuse from overriding controller resolver

Overriding base classes are not best sollution. For examplt now I'm also owerride controller resolver for getting possibility inject camelized arguments into actions. And there is big conflict with this bundle.

So I'm propose: create issue in symfony/symfony repo for providing new event wich help you inject arguments into controllers. I don't know where this event should be triggered, maybe before creating instance of controller, so please, create ticket by youself.

@Inject on protected property produces error

When having the code like this

/**
 * @Service("xxx", scope="request")
 */
class XxxServie
{
    /**
     * @Inject
     * @var \Symfony\Component\HttpFoundation\Request
     */
    public $request;

It produces the

 Fatal error: Cannot access protected property ZZZ\YYY\XXX::$request in .../appDevDebugProjectContainer.php on line ...

Maybe using ReflectionProperty::setAccessible within container should help? or fix the proxy class generator? any ideas?

Error with Base lambda function

Hi,

I have systematically this error after some navigation on the site. But i don't find the solution.

Fatal error: Base lambda function for closure not found in /www/virtualhosts/descriptor/app/cache/dev/jms_diextra/controller_injectors/XXXUserBundleControllerUserController.php on line 7

Please help me.

I use Symfony 2.1 master

Thanks

Bertrand

PerformanceTest and ServiceFinder error

Fatal error: Class 'JMS\DiExtraBundle\Finder\ServiceFinder' not found in vendor\jms\di-extra-bundle\JMS\DiExtraBundle\Tests\PerformanceTest.php on line 43

@Inject null

Is there / should there be a way of injecting null values from annotations?

A use case being when using SonataAdmin, where the first parameter passed to the Admin classes is blank, and then swapped out for the service id by Sonata's configuration compiler.

In XML this is done with: <argument />

In JMS annotations I don't seem to be able to do this, I've tried some other syntaxes- but this seems like it would make sense:

/**
 * @InjectParams({
 *     "code" = @Inject(null),
 *     "class" = @Inject("%...%"),
 *     "baseControllerName" = @Inject("%...%")
 * })
 */
public function __construct($code, $class, $baseControllerName)
{
    ...
}

When exec() is disabled, confusing errors occur

When exec() is disabled on PHP-level, strange errors occur:

PHP Notice: Undefined variable: files in /path/to/app/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/Finder/PatternFinder.php on line 149
PHP Notice: Undefined variable: exitCode in /path/to/app/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/Finder/PatternFinder.php on line 151
PHP Warning: exec() has been disabled for security reasons in /path/to/app/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/Finder/PatternFinder.php on line 149

Only the latter gives an indication of what the cause is. Perhaps it's better to have a centralized check to see if exec() is available (using function_exists()?) and then throw a nice error telling the user what is wrong.

PatternFinder returns an invalid result when using a Symfony Finder

See PatternFinder:

private function findUsingFinder(array $dirs)
{
        $finder = new Finder();

       // cut ...

        return array_keys(iterator_to_array($finder));
}

I think Symfony Finder doesn't return any specific keys, it only returns \SplFileInfo as values.

Replace with:

return array_map(
    function ($file) {  return $file->getPathName(); },
    iterator_to_array($finder));

DI Configuration not synchronized to latest Symfony

The latest Symfony changes (renaming of setInfo to info) are not yet integrated in this bundle:

PHP Fatal error:  Call to undefined method Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::setInfo() in [...]/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/DependencyInjection/Configuration.php on line 67

Bug in CacheWarmer?

Hello Johannes,

Since your last commit 93580cb it looks like there is a major bug in this bundle (or I am using it incorrectly...).

When using JMSSecurityExtraBundle @secure annotations for my controller actions, I get error messages like the following:

Fatal error: JMS\DiExtraBundle\HttpKernel\ControllerResolver::{closure}(): Failed opening required '/home/fwiethof/dev/braintower/tools/symfony/app/cache/dev_new/jms_diextra/proxies/Braintower-SecurityBundle-Controller-GroupController.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/fwiethof/dev/braintower/tools/symfony/app/cache/dev/jms_diextra/controller_injectors/BraintowerSecurityBundleControllerGroupController.php on line 8

(please not the dev_new in the path above)

After reverting back to the previous commit 7409de8 this does not occur anymore.

Any idea?

PS: Thanks a lot for your amazing work and your great contributions to the Symfony ecosystem!

Unresolved dependancy on AOPBundle

I grabbed di-extra-bundle without jms/security-extra-bundle in a symphony-standard and I got a runtime error saying I needed AOPBundle (which is installed with security-extra-bundle but not di-extra-bundle) based on the cache files.

Injecting a collection (array) in constuctor

Hi,

i'm trying injecting an array via InjectParams but cant get it to work (if there is a way its not described in the docs)

Here is what i'm trying to do

/**
 * @param array $options
 * @InjectParams({
 *     "options" = {@Inject("%something%"), @Inject("%something else%")}
 * })
public function __construct(array $options)

This will throw:

[Doctrine\Common\Annotations\AnnotationException]
[Type Error] Attribute "value" of @InjectParams declared on method MyClass::__construct() expects either a(n) JMS\DiExtraBundle\Annotation\Inject, or an array of JMS\DiExtraBundle\Annotation\Injects, but got array.

I tried different syntax variations too but always get an error.

after vendors update get this errors

PHP Fatal error: Call to undefined method Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::setInfo() in .../src/Chewbacca/PaymentBund
php on line 28

<?php

namespace Chewbacca\PaymentBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * This is the class that validates and merges configuration from your app/config files
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
 */
class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritDoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('chewbacca_payment');

        // Here you should define the parameters that are allowed to
        // configure your bundle. See the documentation linked above for
        // more information on that topic.
        $rootNode->children()
                ->arrayNode('qiwi')
                    ->setInfo('qiwi payment configuration')
                    ->canBeUnset()

and this is my composer.json

    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.1.*",
        "doctrine/orm": "2.2.*",
        "doctrine/doctrine-bundle": "dev-master",
        "twig/extensions": "dev-master",
        "symfony/assetic-bundle": "dev-master",
        "symfony/swiftmailer-bundle": "dev-master",
        "symfony/monolog-bundle": "dev-master",
        "sensio/distribution-bundle": "dev-master",
        "sensio/framework-extra-bundle": "dev-master",
        "sensio/generator-bundle": "dev-master",
        "jms/security-extra-bundle": "1.1.*",
        "jms/di-extra-bundle": "1.0.*",

        "doctrine/mongodb": "dev-master",
        "doctrine/mongodb-odm": "dev-master",
        "doctrine/mongodb-odm-bundle": "dev-master",

        "stof/doctrine-extensions-bundle": "dev-master",
        "friendsofsymfony/user-bundle": "dev-master",
        "avalanche123/imagine-bundle": "dev-master",

        "cedriclombardot/admingenerator-generator-bundle": "dev-master",
        "doctrine/doctrine-fixtures-bundle": "dev-master",
        "white-october/pagerfanta-bundle": "dev-master",
        "knplabs/knp-menu-bundle": "dev-master"

    }

Fatal error when running phpunit in test env (debug=true)

When I run PHPUnit (test env, debug mode) I get the following error:

PHP Fatal error:  Class 'EM502b975b856e7_546a8d27f194334ee012bfe64f629947b07e4919\__CG__\Doctrine\ORM\EntityManager' not found in /www/app/app/cache/test/appTestProjectContainer.php on line 231

This is because the Composer Autoloader cannot find the file. How can we fix this?

Cannot inherit from custom base controller

I use version 1.0.1 of this bundle.

In my setup I have a custom base controller, i.e. :

<?php

namespace Acme\CoreBundle\Controller\Base;

use Symfony\Bundle\FrameworkBundle\Controller\Controller as BaseController;
use JMS\DiExtraBundle\Annotation as DI;

/**
 * Controller that provides missing methods for the base controller
 */
class Controller extends BaseController
{
    /**
     * @DI\Inject
     */
    protected $translator;
}

If in my children controller I inject a service, everything works as expected :

<?php

namespace Acme\CoreBundle\Controller\Frontend;

use Acme\CoreBundle\Controller\Base\Controller;

class BarController extends Controller
{
    /**
     * @DI\Inject
     */
    protected $request;

    public function indexAction()
    {
        // Works as expected
    }
}

If I don't inject any service, I get an error like Method "Acme\CoreBundle\Controller\Base\Controller::indexAction" does not exist

<?php

namespace Acme\CoreBundle\Controller\Frontend;

use Acme\CoreBundle\Controller\Base\Controller;

class FooController extends Controller
{
    public function indexAction()
    {
        // Method "Acme\CoreBundle\Controller\Base\Controller::indexAction" does not exist.
    }
}

It looks like it tries to access to the parent controller instead of the children.

Is it an expected behaviour ? How can I fix that ?

Class JMS\DiExtraBundle\Config\FastDirectoriesResource contains 5 abstract methods

Hi,

Updating my deps i've this error :

Fatal error: Class JMS\DiExtraBundle\Config\FastDirectoriesResource contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods (Symfony\Component\Config\Resource\ResourceInterface::getModificationTime, Symfony\Component\Config\Resource\ResourceInterface::exists, Symfony\Component\Config\Resource\ResourceInterface::getId, ...) in XXX/symfony/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/Config/FastDirectoriesResource.php on line 78

Property Injector breaks inheritance chain (in Controllers)

When Using property injection (@Inject annotation) in an abstract controller it breaks the inheritance chain by trying to create an instance of the parent.

Example:

// Base Controller
abstract class BaseController extends Controller
{
    /**
     * @DI\Inject("doctrine.orm.entity_manager")
     */
    private $em;
}
// Child Controller
/**
 * @Route("/users")
 */
class UsersController extends BaseController
{
    /**
     * @Route("/")
     */
    public function indexAction()
    {
        $users = $this->em->getRepository('...');
        return ['users' => $users->findAll()];
    }
}

Custom automatic controller injection broken?

The defaults of request and router seem to come through fine for me, but translator doesn't seem keen with this config, and request will still come through even if I remove it from the array:

jms_di_extra:
    locations:
        bundles: []
        directories: ["%kernel.root_dir%/../src"]

    automatic_controller_injections:
        properties:
            request: "@request"
            router: "@router"
            translator: "@translator"

        method_calls:
            setRouter: ["@router"]

Am I doing something wrong or is there a problem? JMSDiExtraExtension:configureAutomaticControllerInjections() is reading my config in correctly, but no error, and nothing is being passed to my controller action.

FINDSTR search is broken?

I am using bundle on Windows XP and it produces exception, related to FINDSTR execution:

JMS\DiExtraBundle\Exception\RuntimeException: 
Command "FINDSTR /M /S /L /P /D:":\localhost\src" "JMS\DiExtraBundle\Annotation" *.php" exited with non-successful status code. "1".

This issue is caused by substr call in ServiceFinder.php:58 (which removes drive letter in my case):
$cmd .= ' /D:'.escapeshellarg(substr($dirs, 1));

After removing substr call, I was able to run tests, but they still fail with:

Fatal error: JMS\DiExtraBundle\DependencyInjection\Compiler\AnnotationConfigurationPass::process(): 
Failed opening required '  D:\localhost\vendor\bundles\JMS\DiExtraBundle\Tests\DependencyInjection\Compiler/../../Fixture/:'

Further investigation showed that FINDSTR output has different format than bundle expects. In my case following command:

FINDSTR /M /S /L /P /D:"D:\localhost\vendor\bundles\JMS\DiExtraBundle\Tests\DependencyInjection\Compiler/../../Fixture/" "JMS\DiExtraBundle\Annotation" *.php

produced this output:

  D:\localhost\vendor\bundles\JMS\DiExtraBundle\Tests\DependencyInjection\Compiler/../../Fixture/:
LoginController.php
RequestListener.php
Validator\Validator.php

While bundle seem to expect just an array of files with absolute paths and tries to require_once all lines one by one (but first line is just a label of matched dirname in my case).

I want to fix it and send pull request, but not sure if this is bundle's issue or difference in FINDSTR output format in different versions of windows. Can someone confirm that he was able to run current test suit on windows successfuly? (if yes, not sure how this can be fixed at all).

@Autowire

Hey there,

Bundle looks good!

Only thing I noticed is that @autowire would be confusing if you come from other DI libs:

AS3: https://github.com/tschneidereit/SwiftSuspenders [Inject]
C#: http://stefanoricciardi.com/2011/02/04/ninject-mini-tutorial-part-2/ [Inject]
Java/Seam: http://docs.jboss.org/seam/2.2.2.Final/reference/en-US/html/concepts.html#d0e4013 (@in )

Most "injection" annotations are named "In" or "Inject". It would make easier for others to start using this excellent bundle :)

By the way. Can't you reflect if you are injecting on a method/constructor? Would remove the need of @AutowireParams and make it even more simple ;)

Cannot redeclare class error when using 'Controller' as service

I'm in the process of updating my current project to Symfony 2.1 - as part of that, I hit a stumbling block.

I have a number of controllers (extending the Controller class for now, for simplicity) which are also defined as services (not through DiExtra, but simply services.xml).

When attempting to render an action from inside one of these controllers which results in the controller being fetched as a service, a "Cannot redeclare class" error is thrown. In this case, I can see that identical proxy classes are generated in both the 'cache/dev/diextra' and 'cache/dev/jms_aop' folders.

It may sound slightly confusing, so I'll break down the workflow:

  1. Request is routed to [feature]AdminController through the simplified Controller class methods, not as a service
  2. [feature]AdminController renders a view
  3. The view runs {% render 'FusionAdminBundle:Default:sidebar' %} to generate a sidebar
  4. The sidebar controller requests the 'fusion.admin.manager' services, which is injected with each [feature]AdminController as a service
  5. Cannot redeclare class error occurs

This is not an urgent problem as it's rather poor design (currently refactoring it to just use KnpMenu), but it is nevertheless one which can occur.

Bug in cache generation

Symfony 2.0.16 on:

PHP 5.3.2-1ubuntu4.17 with Suhosin-Patch (cli) (built: Jun 19 2012 01:35:33)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with XCache v1.3.0, Copyright (c) 2005-2009, by mOo

Problem: appDevProjectContainer.php file has a wrong service definition. After the command php app/console cache:clear --env=dev --no-debug:

protected function getReplacer_FactoryService()
{
    return $this->services['replacer.factory']
        = new \Acme\HelloBundle\Service\Replacer\NewsletterReplacer();
}

And this is actually wrong. The factory:

use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * @DI\Service("replacer.factory")
 */
class ReplacerFactory
{
    /**
     * @DI\InjectParams({"container" = @DI\Inject("service_container")})
     *
     * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * @param object $object
     * @return type
     * @throws \LogicException
     */
    public function getReplacer($object)
    {
        if($object instanceof \Acme\HelloBundle\Entity\Newsletter) {
            $replacer = new NewsletterReplacer($this->container);
            return $replacer->setInstance($object);
        }

        throw new \LogicException(sprintf("No replacer for class %s.", get_class($object)));
    }
}

And the instance returned by the factory:

class NewsletterReplacer
{

    private $container;

    private $instance;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public function setInstance(Newsletter $newsletter)
    {
        $this->instance = $newsletter;
    }
}

The right cache service definition should be:

protected function getReplacer_FactoryService()
{
    return $this->services['replacer.factory']
        = new \Acme\HelloBundle\Service\Replacer\ReplacerFactory($this);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.