Re: [fw-general] ACL in the Service Layer

2013-11-02 Thread Björn Rylander
I've chosen the approach of; if the command is issued from cli (
php_sapi_name() ) I ignore checking against the acl. I can use this method
since I have control over the server where the application resides and I
know no unauthorized user will execute the application from cli.

If there are better ways I would also be more than happy to know them.

With regards
Björn


2013/11/1 Julian Vidal 

> In a recent Zend Training class, Evan Coury made the point of putting your
> ACL in the Service Layer as opposed to sticking it in each Controller.
>
> While I agree with this, I'm running into an issue with this design and
> would need some advice on how to solve it.
>
> My system needs to run a few cron jobs and I have a couple of Console
> routes. When running via cron there is no user logged in so the ACL will
> naturally block all access to my Service layer.
>
> The only thing that I can think of right now is creating a special admin
> user in the system, storing their credentials in my app config and logging
> them in manually (verifying that this can only be executed from the
> console).
>
> Is this the right way to approach this situation? Can anyone suggest a
> better alternative?
>
> Thanks,
> Julian.
>


Re: [fw-general] ZF2: Using SharedEventManager with context

2013-10-01 Thread Björn Rylander
Thank you that helped. Dumping the result
from $this->getEventManager()->getIdentifiers() in a controller gave me the
identifiers I was looking for.


2013/10/1 Richard Jennings 

> ^ to trigger the event like $this->getEventManager()->trigger('myEvent');
>
> On Tue, Oct 1, 2013 at 9:34 AM, Richard Jennings
>  wrote:
> > The Event Manager you are triggering the event on, say in a specific
> > controller, has an array of Identifier properties.
> >
> > These Identifiers would ordinarily be set in
> > Zend\Mvc\Controller\AbstractController::setEventManager for a
> > controller.
> > $events->setIdentifiers(array(
> > 'Zend\Stdlib\DispatchableInterface',
> > __CLASS__,
> > get_class($this),
> > $this->eventIdentifier,
> > substr(get_class($this), 0, strpos(get_class($this), '\\'))
> > ));
> >
> > The class of the controller has been added as an Identifier to the
> > Controllers Event Manager. (EventManagerAwareInterface on
> > AbstractController causes Event Manager to be set by an initializer).
> >
> > The Shared Event Manager allows attaching an event that can only be
> > triggered by Event Managers with a correct Identifier. From above,
> > this can include inheritance ('Zend\Stdlib\DispatchableInterface') but
> > we can use the controllers class to be more specific.
> >
> > Attach the event to a specific Identifier (the controller)
> > $eventManager->attach('My\Controller\Class', 'myEvent', function($e) {
> > die("it worked!");});
> >
> > so now with an event attached, in your controller you should be able
> > to trigger the event like $this->eventManager->trigger('myEvent');
> >
> >
> > On Tue, Oct 1, 2013 at 8:24 AM, Björn Rylander 
> wrote:
> >> I have no problem attaching an event to a wildcard context and
> triggering
> >> it from a controller. But how do I set the correct context? If I want
> to be
> >> able to trigger an event only from a specific controller, which is the
> >> identifier I should pass as the context variable? I may be reading the
> docs
> >> wrong, but they haven't been any help. If you have an example I would
> >> appreciate it.
> >>
> >> With regards.
> >>
> >> Björn
>


[fw-general] ZF2: Using SharedEventManager with context

2013-10-01 Thread Björn Rylander
I have no problem attaching an event to a wildcard context and triggering
it from a controller. But how do I set the correct context? If I want to be
able to trigger an event only from a specific controller, which is the
identifier I should pass as the context variable? I may be reading the docs
wrong, but they haven't been any help. If you have an example I would
appreciate it.

With regards.

Björn


[fw-general] ZF2 - object instantiation

2013-07-17 Thread Björn Rylander
I'm a little confused regarding the "proper" ZF2 pattern for object
instantiation. I had come to the conclusion that all objects should be
instantiated with factories. But looking at the Album tutorial I can see
that the Album object and the AlbumForm object are directly instantiated in
the AlbumController::addAction(). So, what is the ZF2 pattern for
instantiating objects? Is there a rule when factories should be used or not
used?

With regards
Björn


Re: [fw-general] Re: [zf-contributors] Survey: to composer or not to composer

2013-05-30 Thread Björn Rylander
Loader

I'm used to ZF1 and I haven't had the time to dive into the composer yet.
I'll be sure to check it out once I get a grip of the rest of the ZF2
practices. For someone like me, that have limited time to learn ZF2 before
putting it into production, the loader provides a little more familiarity
to get me going.

Regards,
Björn


2013/5/30 Matthew Weier O'Phinney 

> On Thu, May 30, 2013 at 12:13 PM, Marco Pivetta 
> wrote:
> > Hi everybody!
> >
> > tl;dr: ZF2: do you use composer or Zend\Loader? Simply reply with
> "loader"
> > or "composer" :)
>
> Both.
>
> Modules inside my application that do not need to be re-used will use
> Zend\Loader, while those that are installable via Composer will use
> composer. That said, I don't like to limit installation options for
> users of my modules, either; if they want to add them as git
> submodules, or download them and deflate them into their application,
> that's fine, too -- and that's where having Zend\Loader available as
> an autoloading mechanism makes sense.
>
> Composer simply... simplifies... usage.
>
> --
> Matthew Weier O'Phinney
> Project Lead| matt...@zend.com
> Zend Framework  | http://framework.zend.com/
> PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


[fw-general] Logging in zf2 - what is the preferred method?

2012-12-12 Thread Björn Rylander
I have an application where I want to do extensive logging to a database.
I've found two methods, using the EventManager to attach events to specific
class methods or registering a factory with the ServiceLocator and extract
the log in the controllers and pass it to affected classes.

Which method is the preferred ZF2-style? Is it one of the above or perhaps
some other method altogether? Are there any good examples available?

Regards,
Björn