[fw-general] Status of Zend\Feed
Hello, It seems to me that the Zend\Feed component hasn't gotten much love lately. It still works, but there are some annoying problems: 1.) Building extensions is messy; I find myself having to extend the iTunes extension to build things because there aren't good interfaces or base classes to work with. 2.) Some code style seems outdated -- there are protected methods prefixed by underscores, and this forces me to violate my own project's coding style when I build extensions. I'm just curious whether anyone is planning on updating any of this or whether there's something newer than Zend\Feed that I should be investigating. I'd be happy to discuss this further and/or submit a pull request or two if there's interest in making improvements, but I thought I would check in on the state of the art before investing any significant work into it. thanks, Demian
RE: [fw-general] on getQuery()
It is often useful to wrap commonly-used features like this -- for example, so you can easily test code using mock objects. The defaulting feature is a useful bonus, too, as you observe. This all goes with the framework's overall dependency-injection philosophy -- rather than accessing $_GET (which is a global variable, which allows the code to magically pull values out of the air), wrapping $_GET in the request object provides a more clearly-defined (and easily overrideable) origin for the data. - Demian > -Original Message- > From: dennis-fedco [mailto:dmatve...@fedco-usa.com] > Sent: Thursday, June 12, 2014 10:07 AM > To: fw-general@lists.zend.com > Subject: [fw-general] on getQuery() > > What is the rationale behind using $request->getQuery() vs using $_GET > directly? > > is getQuery() there to provide an Object Oriented way of accessing $_GET, or > is there more to it? > > Because from initial testing ... I do not see much different except the > syntax. > And the ability to use default value, i.e getQuery('var', 'default'); > > > > -- > View this message in context: http://zend-framework- > community.634137.n4.nabble.com/on-getQuery-tp4662135.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- > List: fw-general@lists.zend.com > Info: http://framework.zend.com/archives > Unsubscribe: fw-general-unsubscr...@lists.zend.com > -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] Configuration merging and callables
Actually, after looking more closely at the PHP manual for callables (thanks to the suggestion of a colleague), there is a simple alternative: just use callable strings instead of callable arrays… so: array(‘My\Factory’, ‘myStaticMethod’) becomes: ‘My\Factory::myStaticMethod’ Easy! I'll still consider the possibility of using separate factory classes under some circumstances, but when it makes sense to group stuff together, it looks like this offers the option to do so without breaking overriding. - Demian > -Original Message- > From: Demian Katz [mailto:demian.k...@villanova.edu] > Sent: Wednesday, March 12, 2014 8:31 AM > To: Matthew Weier O'Phinney > Cc: Zend Framework General > Subject: RE: [fw-general] Configuration merging and callables > > That certainly works, but it seems to add an awful lot of clutter – a separate > factory class for every service. My application offers a lot of different > options, so this would add hundreds of files and require PHP to do twice as > much autoloading (which I realize isn’t that expensive, but it has to add up > at some point). I considered putting a static factory method in each class to > cut down on clutter, but this doesn’t seem like good design – it couples > things unnecessarily. Having stand-alone factory classes that group together > related objects seems like the most attractive option from an organizational > perspective. Sounds like it may not be practical, and I know you’re the expert > – but I would be curious to hear if anyone else has successfully approached > this from another angle. If not, I’ll get to work moving all my factories > around a second time. ☺ > > - Demian > > From: Matthew Weier O'Phinney [mailto:matt...@zend.com] > Sent: Tuesday, March 11, 2014 7:32 PM > To: Demian Katz > Cc: Zend Framework General > Subject: Re: [fw-general] Configuration merging and callables > > Use classes that implement __invoke() instead, and reference the class name. > The SM is smart enough to autoload these when requested, making them a more > robust solution than array callbacks - particularly for the use car of > overriding.
RE: [fw-general] Configuration merging and callables
That certainly works, but it seems to add an awful lot of clutter – a separate factory class for every service. My application offers a lot of different options, so this would add hundreds of files and require PHP to do twice as much autoloading (which I realize isn’t that expensive, but it has to add up at some point). I considered putting a static factory method in each class to cut down on clutter, but this doesn’t seem like good design – it couples things unnecessarily. Having stand-alone factory classes that group together related objects seems like the most attractive option from an organizational perspective. Sounds like it may not be practical, and I know you’re the expert – but I would be curious to hear if anyone else has successfully approached this from another angle. If not, I’ll get to work moving all my factories around a second time. ☺ - Demian From: Matthew Weier O'Phinney [mailto:matt...@zend.com] Sent: Tuesday, March 11, 2014 7:32 PM To: Demian Katz Cc: Zend Framework General Subject: Re: [fw-general] Configuration merging and callables Use classes that implement __invoke() instead, and reference the class name. The SM is smart enough to autoload these when requested, making them a more robust solution than array callbacks - particularly for the use car of overriding.
[fw-general] Configuration merging and callables
I've just run into an odd situation - wondering if I'm doing something wrong or if anyone has a recommended workaround. For a long time, my application has had tons of closures in its module.config.php file. Since this is bad practice, I've refactored everything to rely on static factory methods, and I've replaced all the closures with callable arrays... e.g. array('VuFind\Driver\Factory', 'getMyDriver'). So far, so good. The problem is that for my local instance of my application, I have a custom module which overrides some of the factories from the base module. I just updated this to also use callable arrays instead of closures, and the configuration merging code is merging the arrays together, so I end up with something like: array('VuFind\Driver\Factory', 'getMyDriver', 'VuFindLocal\Factory', 'getMyLocalDriver') and then, of course, is_callable() fails, and the whole process blows up. I'm guessing I should be doing something differently somewhere. Any suggestion to which bit I should change? thanks, Demian
RE: [fw-general] Almost ready for 2.3.0!
> I hope that answers your questions! I realize that the change will not be > welcome by everyone, but the rationale for the change is solid. This is reasonable, and we certainly have to move forward sooner or later -- but for now I won't be able to, so put me on the list of people hoping for continued support of 2.2.x for the foreseeable future. I assume that was probably on your agenda anyway, though! :-) thanks, Demian
RE: [fw-general] Almost ready for 2.3.0!
> We're down to the last few pull requests and issues before we're ready > to tag 2.3.0. If you can, I'd really appreciate it if you'd test your > apps against the develop branch of ZF2 ("dev-develop" or "~2.3-dev" if > you use composer), and let us know ASAP if you see any show stoppers. > > Thanks in advance, and here's hoping to a smooth 2.3.0 rollout! I promise I'm not trying to create another PHP version number debate -- just reporting my results. I'm running the current LTS version of Ubuntu and using standard packages -- I imagine that's a fairly common situation. I tried to install 2.3 on my test server to see how my application would behave, and Composer refused because my PHP version is too old. This surprised me since discussions about version requirement changes suggested that the framework was keeping to a fairly conservative course -- I must have missed something. Anyway, please let me know if I'm mistaken about requirements or if the base version was bumped higher than intended... and again, I'm not trying to stir up old battles. Just facing the reality that, while I am eager to take advantage of new PHP language features, and I'm willing to step outside of standard packages for my own personal use, I'm also managing a project that is used by many institutions with conservative server policies who simply aren't going to move past PHP 5.3.3 for some time... so I'm probably going to have to stick with ZF 2.2.x for the moment. - Demian
RE: [fw-general] ZF1 Get errors before redirect
One problem you're facing here is the fact that when PHP throws a fatal error, PHP code stops executing. You can't write PHP code to react to a fatal -- it's too severe. So the first thing I'd recommend doing is figuring out what is causing the "member function on non-object" error, writing some checks to avoid it, and doing something more PHP-friendly (like throwing an exception) if there is a problem. - Demian From: AlexRose [a...@softwarepse.ro] Sent: Friday, January 17, 2014 5:32 AM To: fw-general@lists.zend.com Subject: [fw-general] ZF1 Get errors before redirect As the title says, I want to get all errors before the redirect. So this is my case: I have a select for changing databases(identical structure but different data); So let's say I am here: localhost/user/edit/id/100 (database 1) on db change, I am redirecting the user to the same page, but we load data from database 2. If it is not found, I get an error: "Fatal error: Call to a member function on a non-object ..." How do I catch the errors before the redirect occurs in order to change the url? Thanks! -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/ZF1-Get-errors-before-redirect-tp4661481.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] SSL issue
Bryon, The Curl adapter was also mentioned in this blog post: http://blog.debug.cz/2012/11/https-connections-with-zend-framework-2.html You can set up the adapter using the [Http] section of VuFind's config.ini: [Http] adapter = "Zend\Http\Client\Adapter\Curl" curloptions[CURLOPT_SSL_VERIFYPEER] = true curloptions[CURLOPT_SSL_VERIFYHOST] = 2 curloptions[CURLOPT_CAINFO] = "/etc/ssl/certs/ca-bundle.pem" Let me know if you still have problems -- if that doesn't make a difference, I remain suspicious that you may be having trouble getting values passed from config.ini to the VuFind code. There's a simple sanity check to test if this is the case: set adapter to some garbage string -- if configurations are loading correctly, this will cause a fatal error when the framework fails to load a non-existent class. If setting a bad adapter doesn't break your code, then there is a configuration loading problem. - Demian > -Original Message- > From: Matthew Weier O'Phinney [mailto:matt...@zend.com] > Sent: Monday, September 16, 2013 4:23 PM > To: fw-general@lists.zend.com > Subject: Re: [fw-general] SSL issue > > On Mon, Sep 16, 2013 at 11:02 AM, Bryon Czoch wrote: > > Hi all, > > > > We recently moved our Horizon server behind SSL an we are now getting this > error in Vufind(Built on ZF) on the Record view and cant seem to figure it > out: > > > > Message: Unable to enable crypto on TCP connection libcat.uchicago.edu: make > sure the "sslcapath" option points to a valid SSL certificate directory > > > > We set sslcapath, sslverifypeer and on our FreeBSD server to no avail. > > > > This person had a similar issue: > http://sourceforge.net/mailarchive/message.php?msg_id=31151754 > > > > Any help would be appreciated, > > This is an issue with the underlying stream context being used to > negotiate SSL connections. The most expedient answer, and likely best, > is to use the Curl adapter instead of the default Stream adapter, as > it negotiates SSL more transparently and robustly. > > > > -- > 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 >
RE: [fw-general] ThemeManager
I'm probably not going to have time to study your code closely at the moment (sorry, busy month), but I have built my own theme-management module for the VuFind project. You can find it here: https://github.com/vufind-org/vufind/tree/master/module/VuFindTheme Feel free to take a look and borrow ideas if you see anything you like. I've gone the route of completely separating the themes from the modules (there's a separate themes directory, and themes can inherit from one another), and I expose assets from within the themes directories using some Apache rewrite magic (see the top of https://github.com/vufind-org/vufind/blob/master/config/vufind/httpd-vufind.conf). I'm happy to discuss particular issues if you have questions. - Demian > -Original Message- > From: Juan Pedro Gonzalez [mailto:unaputacue...@hotmail.com] > Sent: Wednesday, September 04, 2013 7:11 PM > To: fw-general@lists.zend.com > Subject: [fw-general] ThemeManager > > Hi, > I'm not sure if this fits here... I'm quite new to Zend Framework 2, but > looking through the code of the framework itself and some other > modules/libraries I've started the development of a ThemeManager library. The > library is located at: > https://github.com/shadowfax/zf-themes > I would be very pleased if someone could take a look at it and send me > comments on bad practices I've made or bad code (I guess there should be some > of those), if someone would contribute that would make me even happier (but > not asking so much). > My main goals are: > Maintain ZF2 views structureEasy to integrateAssets per module and theme. > I've found out some classes are difficult to extend. I've created a new > Mvc/Application just for the init method so it loads my theme service and a > bootstrap listener. If I could hook a global onBootstrap event I guess this > could be neater however initializing the new class makes some sense as it is a > theme application. > I've created a new feature for the modules which tells the ThemeManager that > modules supports and makes use of themes. This way I add the view path from > code. Basically instead of using the 'view' directory I use > 'themes/theme_name' directory to hold the views in the same way the original > directory did If no matching theme exists for a given module it uses the > 'Default' theme. > Assets are located inside 'themes/theme_name/assets/'. The service creates a > route named 'assets' (To be exact the one that is interesting is > '/assets/module/wildcard'. This route is only used for matching and gives us > one parameter which is the module name and a wildcard which is the path to the > asset relative to the assets directory for the module. This way each theme may > contain it's own assets. > Right now I've created one adapter which will use the directory structure and > a json file that gives information about the theme. I'm planning on adding > some new adapter for Database driven theme information (ZF2 database and > Doctrine). > Thanks you for reading untill the end. > -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] RE: [ZF2 2.0.6] ReCaptcha is broken?
I only rolled back the change locally -- I didn't submit a pull request, as I'm not sure what side effects my workaround might have. I suspect it may break some other use cases at the same time that it fixes mine (after all, I assume that the change that caused the problem was accepted for some valid reason in the first place). I believe that Matthew mentioned a few days ago that he was working on a fix for this, so hopefully it will be sorted out soon. - Demian From: cmple [roman.vidya...@gmail.com] Sent: Tuesday, January 08, 2013 5:22 PM To: fw-general@lists.zend.com Subject: [fw-general] RE: [ZF2 2.0.6] ReCaptcha is broken? @demiankatz, is this going into the next release? (2.0.7) demiankatz wrote > Did you see this open issue? > > https://github.com/zendframework/zf2/issues/3267 > > I was able to work around the problem by rolling back this commit: > > https://github.com/zendframework/zf2/commit/66f269f354636c5764a1ae78157347a639ae63f8#library/Zend/Http/Client/Adapter/Socket.php > > - Demian > >> -Original Message- >> From: cmple [mailto: > roman.vidyayev@ > ] >> Sent: Tuesday, January 08, 2013 1:29 PM >> To: > fw-general@.zend >> Subject: [fw-general] [ZF2 2.0.6] ReCaptcha is broken? >> >> Hi, >> >> I get the following error when submitting the form with ReCaptcha: >> >> File: >> >> >> /***/vendor/zendframework/zendframework/library/Zend/Http/Response.php:449 >> >> Message: >> >> *Error parsing body - doesn't seem to be a chunked message* >> >> Stack trace: >> >> #0 >> /***/vendor/zendframework/zendframework/library/Zend/Http/Response.php(303): >> Zend\Http\Response->decodeChunkedBody('false?'An inter...') >> #1 >> /***/vendor/zendframework/zendservice- >> recaptcha/library/ZendService/ReCaptcha/Response.php(133): >> Zend\Http\Response->getBody() >> #2 >> /***/vendor/zendframework/zendservice- >> recaptcha/library/ZendService/ReCaptcha/Response.php(61): >> ZendService\ReCaptcha\Response- >> >setFromHttpResponse(Object(Zend\Http\Response)) >> #3 >> /***/vendor/zendframework/zendservice- >> recaptcha/library/ZendService/ReCaptcha/ReCaptcha.php(496): >> ZendService\ReCaptcha\Response->__construct(NULL, NULL, >> Object(Zend\Http\Response)) >> #4 >> /***/vendor/zendframework/zendframework/library/Zend/Captcha/ReCaptcha.php(221 >> ): >> ZendService\ReCaptcha\ReCaptcha->verify('03AHJ_VuuGz_AWc...', 'sdf') >> #5 >> /***/vendor/zendframework/zendframework/library/Zend/Validator/ValidatorChain. >> php(175): >> Zend\Captcha\ReCaptcha->isValid(Array, Array) >> #6 >> /***/vendor/zendframework/zendframework/library/Zend/InputFilter/Input.php(285 >> ): >> Zend\Validator\ValidatorChain->isValid(Array, Array) >> #7 >> /***/vendor/zendframework/zendframework/library/Zend/InputFilter/BaseInputFilt >> er.php(195): >> Zend\InputFilter\Input->isValid(Array) >> #8 >> /***/vendor/zendframework/zendframework/library/Zend/Form/Form.php(441): >> Zend\InputFilter\BaseInputFilter->isValid() >> #9 >> /***/module/Application/src/Application/Controller/UserController.php(36): >> Zend\Form\Form->isValid() >> #10 >> /***/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractAc >> tionController.php(88): >> Application\Controller\UserController->loginAction() >> #11 [internal function]: >> Zend\Mvc\Controller\AbstractActionController- >> >onDispatch(Object(Zend\Mvc\MvcEvent)) >> #12 >> /***/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager >> .php(464): >> call_user_func(Array, Object(Zend\Mvc\MvcEvent)) >> #13 >> /***/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager >> .php(208): >> Zend\EventManager\EventManager->triggerListeners('dispatch', >> Object(Zend\Mvc\MvcEvent), Object(Closure)) >> #14 >> /***/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractCo >> ntroller.php(107): >> Zend\EventManager\EventManager->trigger('dispatch', >> Object(Zend\Mvc\MvcEvent), Object(Closure)) >> #15 >> /***/vendor/zendframework/zendframework/library/Zend/Mvc/DispatchListener.php( >> 113): >> Zend\Mvc\Controller\AbstractController- >> >dispatch(Object(Zend\Http\PhpEnvironment\Request), >> Object(Zend\Http\PhpEnvironment\Response)) >> #16 [internal function]: >> Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent)) >> #17 >> /***/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager >> .php(464): >> call_user_func(Array, Object(Zend\Mvc\MvcEvent)) >> #18 >> /***/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager >> .php(208): >> Zend\EventManager\EventManager->triggerListeners('dispatch', >> Object(Zend\Mvc\MvcEvent), Object(Closure)) >> #19 >> /***/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(297): >> Zend\EventManager\EventManager->trigger('dispatch', >> Object(Zend\Mvc\MvcEvent), Object(Closure)) >> #20 /***/public/index.php(12): Zend\Mvc\
RE: [fw-general] [ZF2 2.0.6] ReCaptcha is broken?
Did you see this open issue? https://github.com/zendframework/zf2/issues/3267 I was able to work around the problem by rolling back this commit: https://github.com/zendframework/zf2/commit/66f269f354636c5764a1ae78157347a639ae63f8#library/Zend/Http/Client/Adapter/Socket.php - Demian > -Original Message- > From: cmple [mailto:roman.vidya...@gmail.com] > Sent: Tuesday, January 08, 2013 1:29 PM > To: fw-general@lists.zend.com > Subject: [fw-general] [ZF2 2.0.6] ReCaptcha is broken? > > Hi, > > I get the following error when submitting the form with ReCaptcha: > > File: > > > /***/vendor/zendframework/zendframework/library/Zend/Http/Response.php:449 > > Message: > > *Error parsing body - doesn't seem to be a chunked message* > > Stack trace: > > #0 > /***/vendor/zendframework/zendframework/library/Zend/Http/Response.php(303): > Zend\Http\Response->decodeChunkedBody('false?'An inter...') > #1 > /***/vendor/zendframework/zendservice- > recaptcha/library/ZendService/ReCaptcha/Response.php(133): > Zend\Http\Response->getBody() > #2 > /***/vendor/zendframework/zendservice- > recaptcha/library/ZendService/ReCaptcha/Response.php(61): > ZendService\ReCaptcha\Response- > >setFromHttpResponse(Object(Zend\Http\Response)) > #3 > /***/vendor/zendframework/zendservice- > recaptcha/library/ZendService/ReCaptcha/ReCaptcha.php(496): > ZendService\ReCaptcha\Response->__construct(NULL, NULL, > Object(Zend\Http\Response)) > #4 > /***/vendor/zendframework/zendframework/library/Zend/Captcha/ReCaptcha.php(221 > ): > ZendService\ReCaptcha\ReCaptcha->verify('03AHJ_VuuGz_AWc...', 'sdf') > #5 > /***/vendor/zendframework/zendframework/library/Zend/Validator/ValidatorChain. > php(175): > Zend\Captcha\ReCaptcha->isValid(Array, Array) > #6 > /***/vendor/zendframework/zendframework/library/Zend/InputFilter/Input.php(285 > ): > Zend\Validator\ValidatorChain->isValid(Array, Array) > #7 > /***/vendor/zendframework/zendframework/library/Zend/InputFilter/BaseInputFilt > er.php(195): > Zend\InputFilter\Input->isValid(Array) > #8 > /***/vendor/zendframework/zendframework/library/Zend/Form/Form.php(441): > Zend\InputFilter\BaseInputFilter->isValid() > #9 > /***/module/Application/src/Application/Controller/UserController.php(36): > Zend\Form\Form->isValid() > #10 > /***/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractAc > tionController.php(88): > Application\Controller\UserController->loginAction() > #11 [internal function]: > Zend\Mvc\Controller\AbstractActionController- > >onDispatch(Object(Zend\Mvc\MvcEvent)) > #12 > /***/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager > .php(464): > call_user_func(Array, Object(Zend\Mvc\MvcEvent)) > #13 > /***/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager > .php(208): > Zend\EventManager\EventManager->triggerListeners('dispatch', > Object(Zend\Mvc\MvcEvent), Object(Closure)) > #14 > /***/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractCo > ntroller.php(107): > Zend\EventManager\EventManager->trigger('dispatch', > Object(Zend\Mvc\MvcEvent), Object(Closure)) > #15 > /***/vendor/zendframework/zendframework/library/Zend/Mvc/DispatchListener.php( > 113): > Zend\Mvc\Controller\AbstractController- > >dispatch(Object(Zend\Http\PhpEnvironment\Request), > Object(Zend\Http\PhpEnvironment\Response)) > #16 [internal function]: > Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent)) > #17 > /***/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager > .php(464): > call_user_func(Array, Object(Zend\Mvc\MvcEvent)) > #18 > /***/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager > .php(208): > Zend\EventManager\EventManager->triggerListeners('dispatch', > Object(Zend\Mvc\MvcEvent), Object(Closure)) > #19 > /***/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(297): > Zend\EventManager\EventManager->trigger('dispatch', > Object(Zend\Mvc\MvcEvent), Object(Closure)) > #20 /***/public/index.php(12): Zend\Mvc\Application->run() > #21 {main} > > > > > I also found the following thread that attempts to fix a similar issue by > changing the "decodeChunkedBody" method to: > > public static function decodeChunkedBody($body) > { > $decBody = ''; > if (preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", trim($body))) { > while (preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", trim($body), > $m)) { > $length = hexdec(trim($m[1])); > $cut = strlen($m[0]); > > $decBody .= substr($body, $cut, $length); > $body = substr($body, $cut + $length + 2); > } > } else { > return $body; > } > > return $decBody; > } > > source: > http://www.magentocommerce.com/boards/viewthread/9125/P15/#t148838 > > > Any help would be greatly appreciated, > Thanks! > Roman. > > > > > -- > View thi
RE: [fw-general] Zend Framework 2 and SELECT count(*) query
You can use an Expression object to represent function calls within selected columns: use Zend\Db\Sql\Expression; /* ... */ $select->columns(array('num' => new Expression('COUNT(DISTINCT(?))', array('*'), array(Expression::TYPE_IDENTIFIER; (There may be a more efficient syntax -- but hopefully this gives you an avenue to start exploring). - Demian > -Original Message- > From: tm8747a [mailto:thomas.mess...@gmail.com] > Sent: Monday, December 10, 2012 3:26 PM > To: fw-general@lists.zend.com > Subject: [fw-general] Zend Framework 2 and SELECT count(*) query > > I'm trying to do a query like this using Zend Framework 2: > > SELECT count(*) as num FROM mytable > > Here's the code I'm using to build my select statement (bear in mind I've > imported the necessary classes): > > $select = new Select(); > $select->from('mytable') >->columns(array('num'=>'count(*)'), false); > > This code doesn't work because the resulting query is as follows: > > SELECT [count(*)] AS [num] FROM [mytable] > > ...which throws the following error: > > Invalid column name 'count(*)' > > This is caused by the square brackets around count(*). How can I get this to > work properly, basically to have count(*) instead of [count(*)] in the SQL. > Also, I know that you can do it with just a regular query, but I need this > to work with the Select object. As far as I know, this used to work with the > previous versions of Zend, I've seen plenty of solutions for those, but > nothing for Zend Framework 2. > > > > > -- > View this message in context: http://zend-framework- > community.634137.n4.nabble.com/Zend-Framework-2-and-SELECT-count-query- > tp4658383.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- > List: fw-general@lists.zend.com > Info: http://framework.zend.com/archives > Unsubscribe: fw-general-unsubscr...@lists.zend.com > -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] Re: [ZF2] ZfcUser - Clear Sessions before login
I believe I encountered a similar problem, and the only solution I could come up with was to bypass the framework and simply assign: $_SESSION = array(); to empty the session without resetting the state of the surrounding Zend\Session object. I am not proud of this solution! I would love to hear if there is a better way to empty the session contents without officially destroying the session. - Demian > -Original Message- > From: Griesi [mailto:ebert.ch...@gmail.com] > Sent: Thursday, October 25, 2012 9:30 AM > To: fw-general@lists.zend.com > Subject: [fw-general] Re: [ZF2] ZfcUser - Clear Sessions before login > > Sadly this does not work. It seems to be to late. If the Session is destroyed > using this Event it will also destroy a previously initiated Session for > ZfcUser and thus the login does not work. Does anyone have an idea? This is > the whole code: > > public function onBootstrap(\Zend\Mvc\MvcEvent $e) { > $app = $e->getParam('application'); > $em = $app->getEventManager()->getSharedManager(); > $em->attach('ZfcUser\Authentication\Adapter\AdapterChain', > 'authenticate.pre', function($e) { > $session = new \Zend\Session\Container(''); > $session->getManager()->destroy(); > }); > } > > > > > -- > View this message in context: http://zend-framework- > community.634137.n4.nabble.com/ZF2-ZfcUser-Clear-Sessions-before-login- > tp4657794p4657796.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- > List: fw-general@lists.zend.com > Info: http://framework.zend.com/archives > Unsubscribe: fw-general-unsubscr...@lists.zend.com > -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] Contributing improvements to components?
While the Git guide suggests creating branches named for tickets when generating pull requests, you don't have to. You can just give the branch a descriptive name (i.e. hotfix/remove-zend-log-string-dependency) and submit a pull request from there. Discussions can take place on the pull request itself, and if it can't be accepted as-is, the comments there can guide you (i.e. if it needs to be discussed on the lists, or if a ticket needs to be opened, etc.). (Of course, I'm not a project manager here, so perhaps you'll get different suggestions from someone in a more official capacity... but in my experience as a contributor, it doesn't hurt to just go ahead and send a PR, especially if it's relatively simple; if nothing else, it's a good way to get a conversation started). - Demian From: Philip G [guice...@gmail.com] Sent: Friday, October 19, 2012 6:39 PM To: Zend FW General Subject: [fw-general] Contributing improvements to components? What's the process for adding mini-features / improving functionality to components? Currently, I have a few "TODOs" I would like to add: - Add loadModule.post event support to loadModule() within \Zend\ModuleManager\ModuleManager - Improvements to missing features within \Zend\Log\Writer\FirePhp (including adding much needed support for 'extra' parameter). - And possibly: improvements Zend\Log: remove (string) dependency, and make the writers aware (i.e. issue #2638). But I'm not sure what's the process for discussing them, and moving forward. I have ZF2 forked and checked out. But I got stopped at creating a new branch for changes. That would imply creating an issue ticket? Or a feature ticket? I'm a little lost on this part. I have the code changes already locally (albeit in another local copy); I ready to move towards sending pull requests. --- Philip g...@gpcentre.net http://www.gpcentre.net/ -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] [zf2] localized
I don't claim that this is necessarily the best solution, but I've dealt with a similar problem (translating English language names into native versions for all the languages -- i.e. German => Deutsch) by creating a separate language file just for language names and using a custom view helper for displaying them: http://vufind.git.sourceforge.net/git/gitweb.cgi?p=vufind/vufind;a=blob;f=module/VuFind/src/VuFind/Theme/Root/Helper/DisplayLanguageOption.php;h=639da8a7563a42564bca3d47d7b856cfdef366f4;hb=HEAD - Demian From: Bas Kamer [baska...@me.com] Sent: Wednesday, September 26, 2012 9:03 AM To: fw-general@lists.zend.com Subject: [fw-general] [zf2] localized Hi, I'm looking for the zf2 way to translate country names to use in a selectbox (amongst others). I know I can add every full country name to my translation file and call $this->translate('The Netherlands') in my views, but my model would store the country codes not full names. I don't believe ZF2 has something for this at the moment - is that correct? Any suggestions? thanks Bas Kamer -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] ZF2: Access FlashMessenger from view helper
Views are rendered using a hierarchy of ViewModel objects -- the layout only has direct access to the top level, and the ViewModels created by your controller actions are attached as children of the layout... If you need to set values directly in the top-level layout, you can use the layout() controller plug-in. - Demian From: Ralf Eggert [r.egg...@travello.de] Sent: Friday, August 24, 2012 8:29 AM To: fw-general@lists.zend.com Subject: Re: [fw-general] ZF2: Access FlashMessenger from view helper Hi again, actually, I don't get it. My view helper ShowMessages() should be called within my layout script. But I have big problems to pass any variable to the layout script. I had a look at the Layout Controller Plugin, but that did not get me any further. I looked through the reference guide but did not find any answer to it. This leads me to two questions: How can I pass variables to be accessible within my layout script? How can I access the variables from the layout script within a view helper that is called in this layout script? Thanks and best regards, Ralf -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] ZF2: Access FlashMessenger from view helper
As long as your controllers implement the ServiceLocatorAwareInterface (and they probably do already), you can do it like this: $helper = $this->getServiceLocator()->get('viewmanager')->getRenderer()->plugin('helper-name'); Perhaps there is a more direct route, but this is how I've been doing it. Also, it probably goes without saying, but I think using view helpers in a controller is not generally recommended. However, I also understand that sometimes you can't easily avoid it (though it may be a sign that something ought to be refactored). - Demian From: Ralf Eggert [r.egg...@travello.de] Sent: Friday, August 24, 2012 5:03 AM To: fw-general@lists.zend.com Subject: Re: [fw-general] ZF2: Access FlashMessenger from view helper Hi again, additional question. Is it possible to access a view helper from an action controller? Best regards, Ralf -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] ZF2: Access FlashMessenger from view helper
You can simply pass the whole FlashMessenger object to the ViewModel. In my application, I do this by always constructing ViewModels through a createViewModel method in my base controller which sets up the FlashMessenger association: http://vufind.git.sourceforge.net/git/gitweb.cgi?p=vufind/vufind;a=blob;f=module/VuFind/src/VuFind/Controller/AbstractBase.php;h=672473a3df9e9bd25844ada523c03730f38399c5;hb=HEAD ...and then I have a custom View Helper which pulls data out of the FlashMessenger, displays it appropriately and clears the messages: http://vufind.git.sourceforge.net/git/gitweb.cgi?p=vufind/vufind;a=blob;f=module/VuFind/src/VuFind/Theme/Root/Helper/Flashmessages.php;h=7f62451dc735ddaaad1be1ffd9c501a2466d4910;hb=HEAD This allows me to display messages consistently on all screens without having to think too hard about it. I use namespaces that correspond with classes so I can assign messages to different priorities -- hence all the looping in my helper. It's entirely possible that this solution can be improved -- in particular, it would be nice to avoid the need for always calling the createViewModel method. I'm open to suggestions... but as it stands, it works well enough for my needs. - Demian From: Ralf Eggert [r.egg...@travello.de] Sent: Friday, August 24, 2012 5:01 AM To: Zend Framework General Subject: [fw-general] ZF2: Access FlashMessenger from view helper Hi, Is it possible to access the FlashMessenger from a view helper in ZF2? I want to write a view helper that checks the FlashMessenger for any messages and outputs them if any exist. Regards, Ralf -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] ZF2 Forms: add translator to formLabel view helper
> I already wrote my own Listener for my application and I added that to > this listener. Works perfectly. > > Though, do I really need to set the Translator to each form view helper > I want to use? This would be at least formLabel, formSelect and > formMultiCheckbox. > > Or can the translator be set centrally? Have not found anything about > that yet. I haven't worked with the form helpers yet, so I'm not sure exactly how they work... but I seem to recall seeing some discussion about a pattern for injecting translators into helpers. There may be some way to make this happen through DI or service manager configuration, but I'm afraid I don't know the details. Maybe somebody more familiar with these components can help. - Demian -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] ZF2 Forms: add translator to formLabel view helper
Here's some code that I use in my application's bootstrap logic to initialize the behavior of the headTitle() helper: /** * Set up headTitle view helper -- we always want to set, not append, titles. * * @return void */ protected function initHeadTitle() { $callback = function($event) { $serviceManager = $event->getApplication()->getServiceManager(); $renderer = $serviceManager->get('viewmanager')->getRenderer(); $headTitle = $renderer->plugin('headtitle'); $headTitle->setDefaultAttachOrder( \Zend\View\Helper\Placeholder\Container\AbstractContainer::SET ); }; $this->events->attach('dispatch', $callback); } (That comes out of a bootstrap class that I call from my module's onBootstrap method... but you get the idea). You can probably do something similar to set translators, assuming you have access to the necessary translator object at the time that this event triggers. - Demian > -Original Message- > From: Ralf Eggert [mailto:r.egg...@travello.de] > Sent: Wednesday, August 22, 2012 10:07 AM > To: fw-general@lists.zend.com > Subject: [fw-general] ZF2 Forms: add translator to formLabel view helper > > Hi, > > with the new formLabel view helper, I manually need to set the > translator object with the setTranslator() / setTranslatorTextDomain() > methods. I can set this at the top of each view script that uses a form. > > But I would like to set the translator for view helpers within a module > to change the text domain depending on the module. What would be the > best way to do this? The onBootstrap() method of my Module.php? Or some > other place? > > The same problem exists for the formSelect and formMultiCheckbox view > helpers. > > Regards, > > Ralf > > -- > List: fw-general@lists.zend.com > Info: http://framework.zend.com/archives > Unsubscribe: fw-general-unsubscr...@lists.zend.com > -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
[fw-general] RE: Theme inheritance in ZF2
For the benefit of the archives, here is a blog post on the solution I eventually came up with for this problem: http://blog.library.villanova.edu/libtech/2012/06/25/moving-vufind-to-zend-framework-2-part-3-theme-inheritance/ I'm very interested in feedback on my solution if anyone cares to share any. Also, many thanks to saschaH from the IRC channel, who was instrumental in putting me on the right track when I was stuck (by pointing out that another solution to my view resolver problem was simply to push a path stack into the existing view resolver on the fly, outside of the configuration file). - Demian From: Demian Katz Sent: Tuesday, June 19, 2012 3:38 PM To: fw-general@lists.zend.com Subject: Theme inheritance in ZF2 The application I am trying to port from ZF1 to ZF2 uses a theme inheritance system inspired by list8D's solution: http://blogs.kent.ac.uk/list8d/2009/10/29/creating-a-themable-application-in-zend/ Essentially, each theme has its own directory along with a configuration that may specify a parent theme from which it inherits files. A path stack is generated using the current user-selected theme and any parent(s). The themes hold static resources, templates and view helpers. My first obstacle in porting this over is figuring out how to configure ZF2's view resolver to deal with the appropriate path stack. It seems like there are two options: 1.)Do some work to dynamically generate the ['view_manager']['template_path_stack'] value in the module configuration. This seems completely wrong: my application needs to be configured in order to find out which theme is currently active (current theme is determined by a combination of configuration, request parameters and device detection), and any solution involving dynamic configuration generation would run into chicken-and-egg issues. 2.)Write a custom implementation of Zend\View\Resolver\ResolverInterface that deals with theme issues "on demand." This feels like the more appropriate solution, but I'm not sure how to go about telling Zend\Mvc\View\ViewManager to use a custom resolver. A few specific issues: a. The ViewManager's getResolver() method seems rather hard-coded, and I don't see a corresponding setResolver() method. b. Even if there were a setResolver, I'm not sure where best to set this up (presumably it will require hooking an event that's roughly equivalent to ZF1's dispatchLoopStartup plugin method, but my understanding of the new MVC is still a bit fuzzy). c. It's not clear to me how the configuration example in the QuickStart (http://packages.zendframework.com/docs/latest/manual/en/zend.view.html#zend.view.quick-start.usage) correlates to beta4 and the ZendSkeletonApplication example. I'm still very new to ZF2 and have a lot of learning to do, so apologies if I'm missing something obvious - any suggestions or pointers in the right general direction would be greatly appreciated. Also, I understand that this theme solution is not necessarily in line with ZF2's goals of improved efficiency; I do understand why path stacks are not recommended as the default approach. However, for my particular use case, I think I need to sacrifice some performance in the interest of flexibility and extensibility. Obviously, if anyone has a better idea, I'm happy to hear it. Thanks for your time! If I can actually get this working in a reasonable way, I'll be happy to share code with anyone else who might be interested. Demian
[fw-general] Theme inheritance in ZF2
The application I am trying to port from ZF1 to ZF2 uses a theme inheritance system inspired by list8D's solution: http://blogs.kent.ac.uk/list8d/2009/10/29/creating-a-themable-application-in-zend/ Essentially, each theme has its own directory along with a configuration that may specify a parent theme from which it inherits files. A path stack is generated using the current user-selected theme and any parent(s). The themes hold static resources, templates and view helpers. My first obstacle in porting this over is figuring out how to configure ZF2's view resolver to deal with the appropriate path stack. It seems like there are two options: 1.)Do some work to dynamically generate the ['view_manager']['template_path_stack'] value in the module configuration. This seems completely wrong: my application needs to be configured in order to find out which theme is currently active (current theme is determined by a combination of configuration, request parameters and device detection), and any solution involving dynamic configuration generation would run into chicken-and-egg issues. 2.)Write a custom implementation of Zend\View\Resolver\ResolverInterface that deals with theme issues "on demand." This feels like the more appropriate solution, but I'm not sure how to go about telling Zend\Mvc\View\ViewManager to use a custom resolver. A few specific issues: a. The ViewManager's getResolver() method seems rather hard-coded, and I don't see a corresponding setResolver() method. b. Even if there were a setResolver, I'm not sure where best to set this up (presumably it will require hooking an event that's roughly equivalent to ZF1's dispatchLoopStartup plugin method, but my understanding of the new MVC is still a bit fuzzy). c. It's not clear to me how the configuration example in the QuickStart (http://packages.zendframework.com/docs/latest/manual/en/zend.view.html#zend.view.quick-start.usage) correlates to beta4 and the ZendSkeletonApplication example. I'm still very new to ZF2 and have a lot of learning to do, so apologies if I'm missing something obvious - any suggestions or pointers in the right general direction would be greatly appreciated. Also, I understand that this theme solution is not necessarily in line with ZF2's goals of improved efficiency; I do understand why path stacks are not recommended as the default approach. However, for my particular use case, I think I need to sacrifice some performance in the interest of flexibility and extensibility. Obviously, if anyone has a better idea, I'm happy to hear it. Thanks for your time! If I can actually get this working in a reasonable way, I'll be happy to share code with anyone else who might be interested. Demian
RE: [fw-general] ZF2 module namespaces
Wonderful! I guess I just saw things like ZendSkeletonApplication and made an incorrect assumption. Thanks! From: Marco Pivetta [mailto:ocram...@gmail.com] Sent: Tuesday, June 19, 2012 9:52 AM To: Demian Katz Cc: fw-general@lists.zend.com Subject: Re: [fw-general] ZF2 module namespaces Hey Demian, Modules don't need to live at the top of the namespace. You can use as many sub-namespaces as you want! Enjoy ;) Marco Pivetta http://twitter.com/Ocramius http://marco-pivetta.com On 19 June 2012 15:49, Demian Katz mailto:demian.k...@villanova.edu>> wrote: Hello, I'm brainstorming how to adapt my application to ZF2. The software is a web app with a handful of CLI tools. I would like to share as much code between these two areas as possible. I'm thinking of using a primary module to handle the web app, with a secondary module loaded in CLI mode to override routing behavior while recycling other configuration and code. I'm struggling with the naming in this hypothetical situation. If the top-level namespace is supposed to be a vendor, then the logical namespacing would be something like: \MyApp\Module and \MyApp\CLI\Module However, it appears that ZF2 modules have to live in the top of a namespace, so I would end up with something like: \MyApp\Module and \MyAppCLI\Module ...which just doesn't quite feel right. Am I misunderstanding something, or is this a limitation I should just live with? If I have to live with it, are there any conventions I should keep in mind? I'm also interested in comments on my proposed CLI solution, though that is not my primary concern right now. thanks, Demian
[fw-general] ZF2 module namespaces
Hello, I'm brainstorming how to adapt my application to ZF2. The software is a web app with a handful of CLI tools. I would like to share as much code between these two areas as possible. I'm thinking of using a primary module to handle the web app, with a secondary module loaded in CLI mode to override routing behavior while recycling other configuration and code. I'm struggling with the naming in this hypothetical situation. If the top-level namespace is supposed to be a vendor, then the logical namespacing would be something like: \MyApp\Module and \MyApp\CLI\Module However, it appears that ZF2 modules have to live in the top of a namespace, so I would end up with something like: \MyApp\Module and \MyAppCLI\Module ...which just doesn't quite feel right. Am I misunderstanding something, or is this a limitation I should just live with? If I have to live with it, are there any conventions I should keep in mind? I'm also interested in comments on my proposed CLI solution, though that is not my primary concern right now. thanks, Demian
[fw-general] ZF2 migration guide/advice
I'm new here, so feel free to point me to URLs if I'm revisiting familiar territory -- my own searching hasn't been too successful. I'm the lead developer on VuFind (http://vufind.org/), an open source project used by libraries. The software has outgrown its original ad-hoc MVC architecture, so I have been working for the past view months to port it to Zend Framework. I'm extremely happy with the results, but now I'm in an awkward situation: I don't want to release a new version of my software based on a soon-to-be-deprecated architecture (ZF1), nor do I want to use a beta with an unstable API (ZF2). I want to make sure the upgrade process is as painless as possible so it's worthwhile for the (very large) installed base to move forward -- a key piece of that is getting my 2.0 architecture right the first time. I was hoping that a feature-complete ZF 2.0 beta would arrive before I was quite so deep into VuFind 2.0 -- but at this point, my ZF1 prototype is about 95% complete, so I need to start thinking about next steps. A few specific questions: 1.) Working with ZF1 has imprinted its MVC model pretty solidly on my brain. I gather that ZF2 will require some mental adjustments. The ZF2 docs I've seen make me feel like I have to learn ZF2 from the bottom up in order to compare its model against ZF1. Is there (or will there be) a "ZF2 for ZF1 developers" type of guide to help make the learning curve shallower for developers already familiar with ZF1 concepts? 2.) Question 1 is about the high-level mental model, but I'm also interested in the gritty details. VuFind uses many features that will probably change in ZF2: unit tests, plug-ins, helpers, routers, a custom theme system, complex search paths, etc. A breakdown of core ZF1 features showing how they translate to ZF2 would be useful. Perhaps a "recommended migration checklist" would be a good approach, taking a developer step by step from starting with getting the app up using the migration layer, moving on to simple naming convention adjustments, then going into areas where more significant refactoring might be needed, and ending up with a result that fully embraces ZF2 principles. 3.) Is the timeline in the FAQ (spring - complete beta, summer - final release) still accurate? Is the migration layer due with the complete beta or with the final release? Either way, is there anything more I should do to start preparing my code (and my brain) in the meantime? Thanks for your help (and the Framework)! Please let me know if there's anything I can do to make myself useful (i.e. help test/improve documentation). - Demian