[fw-general] Re: [ZF2] Navigation breadcrumbs

2012-11-14 Thread luk
Birzat wrote
 Hi,
 
 I would like to use the navigation but i have a problem :
 
 I make :
*
 'service_manager' = array(
 'factories' = array(
'navigation' =
 'Zend\Navigation\Service\DefaultNavigationFactory',
 ),
 ),
 'navigation' = array(
 'default' = array(
 'home'  = array('type' = 'mvc','route' =
 'home','active'=false,'label' = 'Home','title' = 'Home'),
 'contact'   = array('type' = 'mvc','route' =
 'contact','active'=false,'label' = 'Contact','title' = 'Contact'),
 ),
*
 
 When i make in the layout :
*
 echo
 $this-navigation()-breadcrumbs('navigation')-setMinDepth(0)-setLinkLast(true)-render();
*
 
 In the page home i get 
*
 Home
*
  : it's normal
 But in the page contact i get 
*
 Contact
*
  : but i must have 
*
 Home  Contact
*
To achieve that your contact link should be configured as a child of home
one.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Navigation-breadcrumbs-tp4658086p4658089.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




[fw-general] Re: Multi-Module Conflicting Event Priorities

2012-11-05 Thread luk
nikeshhajari wrote
 Hi,
 
 I was wondering if anyone could explain what is going on for this problem?
 I have an event that is changing the layout of my module and I have
 multiple modules. I noticed that if I change the event priority of the
 layout in one module sometimes the layout from the other module will
 appear instead. Is there anyone to make sure events/event priorities from
 module don't affect another? (namespace of events?)

It should work if you use Namespace as your target, for ie.:
class Module
{
public function init(ModuleManager $moduleManager)
{
$sharedManager =
$moduleManager-getEventManager()-getSharedManager();
$sharedManager-attach(__NAMESPACE__, Mvc::EVENT_DISPATCH,
function($e) {
$controller = $e-getTarget();
$controller-layout('layout/yourlayout');
}, 100);
}



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Multi-Module-Conflicting-Event-Priorities-tp4657903p4657906.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




[fw-general] Re: ZF2: combine authentication with remember me function

2012-10-20 Thread luk
patrioticcow wrote
 thanks for reply.
 
 i am familiar with ZfcUser, well, it works.
 
 but is a bit difficult for me to understand how it works.
 
 im thinking i should do an authentication + acl from scratch by myself, 
 
 then use that module.
 
 or maybe i should ask the creator of that module to do a more in depth
 tutorial on it
 
 thanks again

I think that you can use simply zfcBase + zfcUser + zfcAcl rather than
writing them from scratch. Remember me function you should be able to add
by writing your own module which will extend zfcUser.




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-combine-authentication-with-remember-me-function-tp4656575p4657708.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




[fw-general] Re: PHP Fatal error: Cannot redeclare class PHPUnit_Framework_TestCase

2012-10-19 Thread luk
gaz1234 wrote
 I have received the below error after following the instructions for unit
 testing from 
/
 http://zf2.readthedocs.org/en/release-2.0.3/user-guide/unit-testing.html
/
 
 PHP Fatal error:  Cannot redeclare class PHPUnit_Framework_TestCase in
 /Users/gaz/Sites/zfTest/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php
 on line 98
 
 line 98 of TestCase.php
 
 abstract class PHPUnit_Framework_TestCase extends PHPUnit_Framework_Assert
 implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing
 {
 ...
 
 Versions: 
 ZF2: 2.0.2
 PHPUnit: 3.7.7
 
 In an attempt to fix this I have upgraded to ZF2: 2.0.3
 
 still no joy!
 
 I have gone back over the code to see if I have made a mistake but I can
 not find anything that would cause this error msg.

Make sure you're not running 2 environments or configs for PHPUnit. Looks
like you're including somewhere  twice the same class class
PHPUnit_Framework_TestCase from 2 different sources.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/PHP-Fatal-error-Cannot-redeclare-class-PHPUnit-Framework-TestCase-tp4657687p4657691.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




[fw-general] Re: ZF2: combine authentication with remember me function

2012-10-19 Thread luk
patrioticcow wrote
 hi, have you ever figure this out?
 
 i am trying to build a simple authentication from scratch, just so i can
 learn more, 
 but i can't yet figure it out.
 
 Do you mind sharing some code in this regard?

Try this plug and play module for user authentication, courtesy of ZF
Commons ( https://github.com/ZF-Commons https://github.com/ZF-Commons  )
https://github.com/ZF-Commons/ZfcUser
https://github.com/ZF-Commons/ZfcUser  



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-combine-authentication-with-remember-me-function-tp4656575p4657692.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




[fw-general] Re: Language Route

2012-10-18 Thread luk
Paladyn wrote
 Sorry for duplicating post but first Subject wasn`t clear enough and I`m
 really stuck at this...
 
 I`m trying to set some action (event) on flag to change language Param and
 redirect to previous route.
 
 lang/admin/controller/action/id - clicking on flag - set change lang
 param - go back to lang/admin/controller/action/id
 
 There are two ways of doing it I can find myself:
 Set some event on flag to change lang Param and relunch controller action
 (I have big problem with that).
 
 Getting route match in bootstrap then pass vars to view (passing variables
 from bootstrap to view is`t best thing probably...)  and write full route
 with different language on flag (with different language set).
 
 I will be very grateful for any tips/help.

Oh man, I think solution to that is quite simple. Let's say you are on page
http://site.com/en/admin/article/get/id/5. Then you've got header where you
got your flags as links. You can go here two ways: 
- construct links using url helper by using current route name and override
language param per each language, so you would have something like:
http://site.com/de/admin/article/get/id/5
or
http://site.com/pt/admin/article/get/id/5
- second way is to generate urls with nly language code bit, lke:
http://site.com/de
http://site.com/pt
Disadvantage here is that somehwa you would need to redirect back to
previous url which can be achieved by registering it in session

Once you got that then onBoostrap on dispatch event you need to use
RouteMatch to detect and change locale and in the first case above you will
redirect to the same route with new language code and in the second case use
session to read old location.

I hope it makes sense now.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Language-Route-tp4657679p4657680.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




[fw-general] Re: Setting global value

2012-10-16 Thread luk
Paladyn wrote
 I`m a bit confused in this one.
 Of course I started from setting :lang in all models routes.
 Should I build event dispatch in every Module separately or there is a way
 to make it global (in bootstrap?)? How to get right route if some of
 parameters are set in some controllers. And how to get route which was set
 before clicking on flag.
 I feel this is very simple but I`m just a bit dumpass here.
 
 Btw. thanks luk for all help, all answered questions in threads I make
 here!

Yes you can do it in one Module globally onBootstrap. To make it global per
controller attach it to every AbstractController on dispatch, like:

public function onBootstrap($e)
{
$sharedEvents =
$e-getApplication()-getEventManager()-getSharedManager();
   
$sharedEvents-attach('Zend\Mvc\Controller\AbstractActionController',
'dispatch', function($e) {
$controller   = $e-getTarget();
$matchedRoute = $controller-getEvent()-getRouteMatch();
$routeMatchLang = $matchedRoute-getParam('lang');

if (in_array($routeMatchLang, array('de','en'))) {
   // set locale here
}
// redirect back
return $controller-redirect()-toRoute('lastRoute');
});
}



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Setting-global-value-tp4657568p4657642.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




[fw-general] Re: ZF2 - Integrating Third Party Libraries

2012-10-16 Thread luk
electricowl wrote
 Hi,
 
 I'm building a new application around Zend Framework 2. The application
 will require the use of third party libraries including the one I'll be
 writing.
 
 The problem I am having is that there are no really clear examples of how
 to integrate a library into the /vendors subdirectory.
 
 One issue is that there is no explicit description of how to add a
 library. How to set up the include paths and importantly how to make the
 application aware of the library. 
 
 How would I integrate vendors/FooLibrary into my ZF2 application?

You can distribute your library the same way like any 3rd party modules that
are currently available by using composer ( http://getcomposer.org/
http://getcomposer.org/  ). You don't need to setup any include_paths, it
can be done by autoloading which is also handled by composer. Download the
latest ZendSkeletonApplication here (
https://github.com/zendframework/ZendSkeletonApplication
https://github.com/zendframework/ZendSkeletonApplication  ) and check it's
composer.json settings how its dependencies have been setup. Package
dependencies setup there are registered with packagist most fo the time look
here  https://packagist.org/packages/zendframework/zendframework
https://packagist.org/packages/zendframework/zendframework  

Other option is to use git submodules as your dependencies. Google is your
friend to find more details about it and I hope given directions will help
you.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Integrating-Third-Party-Libraries-tp4657635p4657643.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




[fw-general] Re: Replace Album tutorial route with title instead of ID

2012-10-16 Thread luk
fwahlqvist wrote
 Hi Luke,,
 
 Thank you for your great input, I have updated the changes below as you
 mentioned, the url changes works fine but when I try to edit the form is
 displaced but when I press edit I get rerouted to the add new module
 instead. Looking closer at the code a noticed the the form post action
 have changed to 
 form action=/album/edit method=post name=album id=album
 i.e. the action have changed and droped the id, tryied to update code but
 no luck, any ideas or suggestions?

Yes, it happened because you need to pass that id correctly back to form:

public function editAction()
{
$title = (int)$this-params()-fromRoute('title', '');

if (!empty($title)) {
return $this-redirect()-toRoute('album',
array('action'='add'));
}

$album = $this-getAlbumTable()-getAlbum($title);
$form = new AlbumForm();
$form-bind($album);
$form-get('submit')-setAttribute('value', 'Edit');

$request = $this-getRequest();
if ($request-isPost())
{
$form-setData($request-getPost());
if ($form-isValid()) {
$this-getAlbumTable()-saveAlbum($album);
// Redirect to list of albums
return $this-redirect()-toRoute('album');
}
}

return array(
'id'   = $album-id, // change here to pass id form album
'form' = $form,
);
}



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Replace-Album-tutorial-route-with-title-instead-of-ID-tp4657571p4657644.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




[fw-general] Re: Zend Form, Fieldset attributes

2012-10-15 Thread luk
miszyman wrote
 mhm still didn't manage to do it.. any help? to be more specific I want to
 set the foo attr with boo value in the fieldset:
 fieldset foo=boo
 legend
 label
 /legend
 /fieldset

Zend\Form\Fieldset should not be used to create fieldset/fieldset markup
and I think it does not anyway.
Use static html around your form elements in the view.
fieldset foo=boo
legendlabel/legend
?php echo $this-formRow($form-get('somelement'))?
/fieldset



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Form-Fieldset-attributes-tp4657402p4657599.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




[fw-general] Re: autoloader example?

2012-10-15 Thread luk
Tim Rupp wrote
 Thanks for the reply, it helped me get the autoloader working.
 
 Follow-up question. I dont suppose it's possible to autoload ZF2
 libraries, as well as ZF1 libraries in the same sentence is it?
 
 something like
 
 $var = new \Zend\Http\Client
 
 and
 
 $var2 = \Zend_Http_Client
 
 Where the first example would load the ZF2 library and the second
 would load the ZF1 library
 
 Thoughts?

You can still do that but you would need to register different namespace
namess for ZF1 and ZF2, for ie Zend and Zend2.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/autoloader-example-tp4657613p4657620.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




[fw-general] Re: Router not worked as expected

2012-10-15 Thread luk
mjapex wrote
 Actually I have nothing to do with route (no any coding), but the
 configurations.
 
 For generated url, here is the code. 
 $this-url(array(
 'controller'=$this-controller, 
 'action'=$this-action,
 'country'=$this-country, 
 'state'=$this-state, 
 'city'=$city), 
 'apts-city');
 
 Following print out parameters came from url,
 http://localhost/rent/United+States/New+York/New+York/3
 
 Array ( [controller] = rent [country] = United States [state] = New
 York [city] = New York [subcity] = 3 [action] = subcity [page] = 0 ) 

You can clearly see from your debug that your parameters are not being
matched correctly.Looks like your subcity param is being mixed with page.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Router-not-worked-as-expected-tp4657584p4657621.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




[fw-general] Re: Extend Zend\Form\Form to output a div or article instead of input type text

2012-10-14 Thread luk
fwahlqvist wrote
 Thank you for getting back to me.
 
 I am aware that I can edit the .phtml file, the reason i want to change
 the type is because i would like to make the div an editable region with a
 jquery script and then save with the form features

In this case you would need to create your own
Zend\Form\Element\YourCustomElement class and a view helper for it.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Extend-Zend-Form-Form-to-output-a-div-or-article-instead-of-input-type-text-tp4657572p4657580.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




[fw-general] Re: Name spacing controllers

2012-10-14 Thread luk
Steve Rayner-2 wrote
 Using ZF2 I need to namespace my controllers because i have the same
 controller names in different modules (ie index controller). If i
 don't name space them some get lost in merged config. So my
 controllers are named as;
 
 'controllers' = array(
 'invokables' = array(
 'Inventory/Index' = 'Inventory\Controller\IndexController',
 'Inventory/Items' = 'Inventory\Controller\ItemsController',
 'Inventory/Categories' =
 'Inventory\Controller\CategoriesController',
 'Inventory/Locations' =
 'Inventory\Controller\LocationsController'
 )
 )
 
 I would like my URLs to look like this;
 
 http://mysite/inventory/items/edit/1
 
 I don't want to create a seperate route for each controller, because
 if i have 50 controllers i don't want to have 50 routes. That would be
 crazy.
 So i tried to set up a route like this;
 
 'route' = '\inventory[\:controller[\:action][\:id]]',
 'default' = array(
 'controller' = 'Index',
 'action'  'Index'
 )
 
 However this doesn't work because it looks for a controller named
 index. I need a way of adding a namespace.
 I would have thought this is a fairly normal use case. Basically as per
 ZF1.
 
 Having seperate routes for each controller is a major problem for me.
 To give an example i have added just five controllers so far and i
 already  have over 120 lines of config code. All of it is just
 repeated blocks of code only the controller name is different. That's
 madness there has to be a better way.
 
 Is there any way of namespacing controllers and still have a
 controller parameter in the url and retain clean urls?
 I've been looking at the '__NAMESPACE__' array key. However it does
 not seem to have any effect. I've looked through the framework code
 and the only place i can find it is in
 Zend\Mvc\ModuleRouteListener.php (Line 22). This is used in the
 function onRoute(McvEvent e$). However placing echo and die statements
 in this functions leads me to beieve it is never invoked. So I must be
 on the wrong track.
 
 Any advice appreciated.

Did you try to use standard ZendSekeleton app single route for all your
modules that need /inventory uri:
'inventory' = array(
'type'= 'Literal',
'options' = array(
'route'= '/inventory',
'defaults' = array(
'__NAMESPACE__' = 'Application\Controller',
'controller'= 'Index',
'action'= 'index',
),
),
'may_terminate' = true,
'child_routes' = array(
'default' = array(
'type'= 'Segment',
'options' = array(
'route'= '/[:controller[/:action[/:id]]]',
'constraints' = array(
'controller' = '[a-zA-Z][a-zA-Z0-9_-]*',
'action' = '[a-zA-Z][a-zA-Z0-9_-]*',
'id'   = '[0-9]+',
),
'defaults' = array(
),
),
),
),
),



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Name-spacing-controllers-tp4657577p4657582.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




[fw-general] Re: ZF2 and understanding routes.

2012-10-14 Thread luk
ryanrk wrote
 Yes,  that did it.  So we need to add an invokable for every controller?

Yes, it is one of possible options to add your Controller into invokables.
The other option would be to create your Controller with a Factory and by
using Service Manager inject needed dependencies.


ryanrk wrote
 Is there an easy way to make the routes default to a module so the module
 name isn't in the URL?
 Localhost/test instead of localhost/module/test

To achieve this just use / in parent route and remove first forward slash
from child route:
'application' = array(
'type'= 'Literal',
'options' = array(
'route'= '/', // updated here...
'defaults' = array(
'__NAMESPACE__' = 'Application\Controller',
'controller'= 'Index',
'action'= 'index',
),
),
'may_terminate' = true,
'child_routes' = array(
'default' = array(
'type'= 'Segment',
'options' = array(
'route'= '[:controller[/:action]]', // and
here
'constraints' = array(
'controller' = '[a-zA-Z][a-zA-Z0-9_-]*',
'action' = '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' = array(
),
),
),
),
),



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-and-understanding-routes-tp4657579p4657585.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




[fw-general] Re: Router not worked as expected

2012-10-14 Thread luk
mjapex wrote
 I have router configuration as following.
 
 resources.router.routes.apts-city.route =
 :controller/:country/:state/:city/:page
 resources.router.routes.apts-city.defaults.controller = rent
 resources.router.routes.apts-city.defaults.action = city
 resources.router.routes.apts-city.defaults.page = 0
 resources.router.routes.apts-city.regs.page = \d+
 
 resources.router.routes.apts-subcity.route =
 :controller/:country/:state/:city/:subcity/:page
 resources.router.routes.apts-subcity.defaults.controller = rent
 resources.router.routes.apts-subcity.defaults.action = subcity
 resources.router.routes.apts-subcity.defaults.page = 0
 resources.router.routes.apts-subcity.regs.subcity = [^0-9]+
 resources.router.routes.apts-subcity.regs.page = \d+
 
 
 The request, http://localhost/rent/United+States/New+York/New+York/2,
 should go to city action. But it went to subcity action.
 
 I can't figure out what's wrong about it. Please help.
 
 I did try on Zend Framework 1.11.3 and Zend Framework 1.12.0. Got same
 result.

It looks like the number of params in your URL do not match the correct
route.
Try to add matching of :city param to both of your routes, smthg like:

resources.router.routes.apts-subcity.regs.city = [a-zA-Z][a-zA-Z0-9_-]*





-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Router-not-worked-as-expected-tp4657584p4657586.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




[fw-general] Re: Router not worked as expected

2012-10-14 Thread luk
mjapex wrote
 I added it to my routers as following. But the results are same.
 
 resources.router.routes.apts-city.route =
 :controller/:country/:state/:city/:page
 resources.router.routes.apts-city.defaults.controller = rent
 resources.router.routes.apts-city.defaults.action = city
 resources.router.routes.apts-city.defaults.page = 0
 resources.router.routes.apts-city.regs.city = [a-zA-Z][a-zA-Z0-9_-]*
 resources.router.routes.apts-city.regs.page = \d+
 
 resources.router.routes.apts-subcity.route =
 :controller/:country/:state/:city/:subcity/:page
 resources.router.routes.apts-subcity.defaults.controller = rent
 resources.router.routes.apts-subcity.defaults.action = subcity
 resources.router.routes.apts-subcity.defaults.page = 0
 resources.router.routes.apts-subcity.regs.city = [a-zA-Z][a-zA-Z0-9_-]*
 resources.router.routes.apts-subcity.regs.subcity = [^0-9]+
 resources.router.routes.apts-subcity.regs.page = \d+

Are you using  url helper to create that URL and are you passing a route
name to have it generated?




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Router-not-worked-as-expected-tp4657584p4657589.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




[fw-general] Re: Router not worked as expected

2012-10-14 Thread luk
mjapex wrote
 Yes, I am passing the router name and using url helper to generate url.

Then it should not go to city or subcity if you passing the correct one.
apts-city should be passed  as a name, Check also if you're passing route
name in correct place. Can you paste that code where you construct that
route?



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Router-not-worked-as-expected-tp4657584p4657591.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




[fw-general] Re: Setting global value

2012-10-13 Thread luk
Paladyn wrote
 I wonder what is best way to set global language value and automatically
 pass it to url (clicking to a flag redirects to same place where user is,
 but with different language)?

You can create a language code route param in your routes, then on flag put
a url something like http://mysite.com/de which then from dispatch event
will detect that language, set it and redirect back user where he was.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Setting-global-value-tp4657568p4657574.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




[fw-general] Re: Replace Album tutorial route with title instead of ID

2012-10-13 Thread luk
fwahlqvist wrote
 Hi All,
 
 I am trying to update the ablum module tutorial to us title instead as
 id in the route, 
 I have updated the route in module.config.php to 
 'route' = '/article[/:action][/:title]',
 however I am unsure on how I should update the AlbumController editAction
 and the edit.phtml to use title instead of ID, do I also need to update
 the AlbumTable.php?
 
 All guidance welcome
 
 Thanks in advance

You would need to only change id parameter from id to title in all the
palces where it's being passed to fetch an Album.

Controller changes:
public function editAction()
{
$title = $this-params()-fromRoute('title', '');

if (!empty($title)) {
return $this-redirect()-toRoute('album',
array('action'='add'));
}

$album = $this-getAlbumTable()-getAlbum($title);

Model\AlbumTable changes:
Change all the $id references to $title

public function getAlbum($title)
{
$rowset = $this-select(array('title' = $title));
$row = $rowset-current();

if (!$row) {
throw new \Exception(Could not find row $title);
}

return $row;
}

public function saveAlbum(Album $album)
{
$data = array(
'artist' = $album-artist,
'title'  = $album-title,
);

$id = (int)$album-id;

if ($id == 0) {
$this-insert($data);
}
else {

if ($this-getAlbum($title)) {
$this-update($data, array('id' = $id));
}
else {
throw new \Exception('Form id does not exist');
}
}
}



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Replace-Album-tutorial-route-with-title-instead-of-ID-tp4657571p4657575.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




[fw-general] Re: Extend Zend\Form\Form to output a div or article instead of input type text

2012-10-13 Thread luk
fwahlqvist wrote
 Hi All,
 
 I want to change the behaviour of Zend\Form\Form to change the output type
 to be a 
 div
  or an article instead. I am currently using the album tutorial as a
 training ground and planing to have a look to use a editable region
 instead to save the data. 
 All help and guidence re welcome.

You don't need to change behaviour of the Form element. Just go to your view
for ie.view/album/album/edit.phtml and put your div tags anywhere you like.
You can render form elements separately and they don't have any html
containers markups.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Extend-Zend-Form-Form-to-output-a-div-or-article-instead-of-input-type-text-tp4657572p4657576.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




[fw-general] Re: Mocking in zf2 is not such easy

2012-10-10 Thread luk
pablofmorales wrote
 I trying to use baby steps with ZF2, but  I found several issues.
 
 In the first instance I can't run my phpunit test case because this
 error
 https://github.com/timdev/ZendSkeletonModule/commit/52c71b8d5f6497c822c5a0f3b2b172af5b16016c
 
 I use ZendSkeletonModule, with this fix I continue, but the problem is
 when I try to mock a model, in the controller.
 
 In the example here
 http://framework.zend.com/manual/2.0/en/user-guide/database-and-models.html
 we configure the module indicating the name of the class, and
 namespaces, how I can mock this object?
 
 The only way, I supuse,  is using DI, but why you don't use a good
 example in the first time?
 
 I would like to know if exists a module example well done, with TDD.
 
 
 
 
 
 Pablo Morales
 blog: http://blog.pablo-morales.com
 linkedln: http://www.linkedin.com/pub/9/528/21
 skype: pablofmorales
 gtalk: 

 pablofmorales@

 msn: 

 pfm_mc@

 
 -- 
 List: 

 fw-general@.zend

 Info: http://framework.zend.com/archives
 Unsubscribe: 

 fw-general-unsubscribe@.zend


I recommend you to read here on TDD with ZF2 (courtesy by Tom Oram):
http://devblog.x2k.co.uk/ http://devblog.x2k.co.uk/  




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Mocking-in-zf2-is-not-such-easy-tp4657469p4657475.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




[fw-general] Re: resolver could not resolve to a file for non-view Application.

2012-10-08 Thread luk
Philip Gabbert wrote
 On Sat, Oct 6, 2012 at 9:18 AM, luk lt;

 luke@

 gt; wrote:
 

 I suggest to read this post:

 http://zend-framework-community.634137.n4.nabble.com/Exceptions-not-displayed-td4657358.html
 
 http://zend-framework-community.634137.n4.nabble.com/Exceptions-not-displayed-td4657358.html
 



 If I'm reading this correctly, it's saying it's currently not possible to
 catch the event. Just want to make sure I'm seeing what you're directing.
 It technically doesn't answer my question, but appears it may indirectly.
 The error is attempting to render a
 404: 'Zend\View\Renderer\PhpRenderer::render: Unable to render template
 404; resolver could not resolve to a file'
 
 However, since I'm using view files, I don't even want this action. Is
 there a way to overload the View class (like in ZFW1.x)?
 
 Is there some temporary default file I can put into place so I can see
 what's happening? I've tried mapping view/error/404.phtml. I've tried
 putting in the 404 from the skeleton project. None of them allows the 404
 to actually render...
 
 ---
 Philip

Post your code form Module.php class and from application config please then
I may be able to help.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/resolver-could-not-resolve-to-a-file-for-non-view-Application-tp4657385p4657429.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




[fw-general] Re: ZF2 Form Select Element - JSON updated - Validation

2012-10-06 Thread luk
Paladyn wrote
 I`m try to build multiselect form (select depend from each other, data for
 depended select is injected with JQuery + JSON).
 Everything works fine until validation (error:The input was not found in
 the haystack) . I think it`s some sort of security problem (prevents from
 injecting select options into code). I wonder if there is a way, to inject
 JSON data into form registered array.

I had the same issue before. The solution is very straightforward though.
Instead of returning a list of values by JSON to be fed into your Form
Element, construct and return new Form Element with values and replace the
old one with this content.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Form-Select-Element-JSON-updated-Validation-tp4657381p4657395.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




[fw-general] Re: resolver could not resolve to a file for non-view Application.

2012-10-06 Thread luk


Philip Gabbert wrote
 (This is resend as I believe my original emails weren't going through --
 sent via my personal email, vs my gmail email)
 
 I'm writing a purely REST based application--ie: no view.
 
 How do I get around this Zend\View exception:
 
 - Uncaught exception 'Zend\View\Exception\RuntimeException' with message
 'Zend\View\Renderer\PhpRenderer::render: Unable to render template 404;
 resolver could not resolve to a file'
 
 On a 404, I want it to route to a specific Module Controller, with
 specific
 parameters, or at least something to identify what the error was--pretty
 much exactly what ErrorController was in ZF1.0--in order to output the
 proper REST header and body format.

I suggest to read this post:
http://zend-framework-community.634137.n4.nabble.com/Exceptions-not-displayed-td4657358.html
http://zend-framework-community.634137.n4.nabble.com/Exceptions-not-displayed-td4657358.html
  



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/resolver-could-not-resolve-to-a-file-for-non-view-Application-tp4657385p4657396.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




[fw-general] Re: Models in modules

2012-10-04 Thread luk
kirens...@yahoo.com wrote
 I have a project structure created using zend tool. It has some modules in
 it. Each module has its own controller, model and view directories. I want
 to autoload classes in model directories without any prefixes infront of
 it. It must be invoke like this
 
 $obj  = new Users();
 
 After reading the posts I understood that it is not possible to  load
 modules models like this. But still I am in confusion, Is my understanding
 is correct or not? Please help me friends ...
 Thanks in advance .
 Kiren.S

Just add your models into include_path in your public/index.php file, 
something like that:
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)).;.realpath(APPLICATION_PATH . '/models'));



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Models-in-modules-tp4657312p4657314.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




[fw-general] Re: ZF2 How to change template directory

2012-10-02 Thread luk
MGP wrote
 
 luk wrote
 Hi, setTemplate and setLayout functions change the default layout
 template that is being used. Clearly what you're trying to achieve here
 is to change default views path and you can easily do so by overriding
 your template_path_stack. Try this:
 
 class Module
 {
 // ...
 
 public function init(ModuleManager $moduleManager)
 {
 $sharedEvents =
 $moduleManager-getEventManager()-getSharedManager();
 $sharedEvents-attach(__NAMESPACE__, 'dispatch', function($e) {
 $serviceManager = $e-getApplication()-getServiceManager();
 $templatePathResolver =
 $serviceManager-get('Zend\View\Resolver\TemplatePathStack');
 $templatePathResolver-setPaths(array(__DIR__ .
 '/view/blue')); // here is your skin name
 
 }, 100);
 }
 }
 Doing that, for some reason, breaks the code. It causes: Unable to render
 template application/index/index;
 It always try to load the default view (in the default dir) for that
 module/controller/action, even if you remove that path from the stack. (I
 still cant understand why...)
 
 Instead of using setPaths, can you just add a new path to the stack?
 (using the -addPath(__DIR__ . '/view/blue')

You can use addPath method, it works as well. Your error may be related to
some routes configuration being overriden. Just to test it please try to
create a separate module with new route instead of the Application one. Then
use that template stuff switch in the same way. For me it works fine.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-How-to-change-template-directory-tp4656995p4657298.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




[fw-general] Re: zf2 Modules - Application is comparable to the old default ?

2012-10-01 Thread luk
whisher wrote
 Hi all,
 I'm just taking my first steps with zf2 and modules
 so I'm wondering Is it required a module Application like in the
 getting started tutorial ?
 I set up my first project from scratch and I got
  Uncaught exception 'Zend\View\Exception\RuntimeException' with message
 'Zend\View\Renderer\PhpRenderer::render: Unable to render template 404
 
 Bye

You can also start from pulling ZendSkeletonModule and renaming it to your
required name.
https://github.com/zendframework/ZendSkeletonModule
https://github.com/zendframework/ZendSkeletonModule  

Personally I recommend to use ZendSkeletonApplication. It gives you better
overview from the start.
https://github.com/zendframework/ZendSkeletonApplication
https://github.com/zendframework/ZendSkeletonApplication  



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/zf2-Modules-Application-is-comparable-to-the-old-default-tp4657237p4657253.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




[fw-general] Re: Business logic inside controller

2012-10-01 Thread luk
Webdevilopers wrote
 I have senn a lot of examples for ZF form handling already like this one:
 Zend Framework 2 : Create Simple Upload Form with File Validation
 http://samsonasik.wordpress.com/2012/08/31/zend-framework-2-creating-upload-form-file-validation/
   
 
 The business logic (handling file upload etc.) takes place inside the
 action of the controller:

 
 Regarding the fat model, skinny controller strategy are these examples
 for keeping it simple to understand the sequence of logic? Isn't it best
 practice to create a service class to handle the whole process to make the
 code re-usable and keep the controller skinny?
 
 What do you think?

It's entirely up to you. I would use a strategy based on the size of your
application. If your application is relatively small and has got only few
controllers it is ok to have logic inside them. If it's significantly larger
then I would use Service layer.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Business-logic-inside-controller-tp4657256p4657267.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




[fw-general] Re: Zend Form - Checkbox in Form constructor

2012-09-28 Thread luk
Paladyn wrote
 Is there a way to add checkbox (or other) elements in form constructor
 like this:
 
 $this-add(array(
  'name' = 'checkbox',
  'attributes' = array(
'type'  = 'checkbox',
  ),
  'options' = array(
'label' = 'CheckBox',
  ),
 ));
 
 After using echo $this-formCheckbox($form-get('checkbox'));
 
 In view I`m getting error: Fatal error: Uncaught exception
 'Zend\Form\Exception\InvalidArgumentException' with message
 'Zend\Form\View\Helper\FormCheckbox::render requires that the element is
 of type Zend\Form\Element\Checkbox'
 
 So $this-add is`t creating right object based on attributes-type.
 
 Of course everything works right after this way:
 
 $checkbox = new Element\Checkbox('checkbox');
 $checkbox-setLabel('CheckBox');
   
 $this-add($checkbox);
 
 But first way seems a bit faster for me (If it would be working).

You're setting wrong keys, try this:
$this-add(array(
'type' = 'Zend\Form\Element\Checkbox',
'name' = 'Name',
'options' = array(
'label' = 'Name:',
'class' = 'cssClass',
//'value_options' = array('man'=1,'woman'=2)
),
));




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Form-Checkbox-in-Form-constructor-tp4657206p4657207.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




[fw-general] Re: bootstrap event to change template

2012-09-26 Thread luk
MGP wrote
 Hello, i'm trying to change the template in the dispatch event, by
 catching a variable setted on the controller and using it to set the
 template.
 
 Like this:
 
 Controller:
 
 public function indexAction ()
 {
 return new \Zend\View\Model\ViewModel(array(
 'layout' =BASE_PATH . '/template/default/example.phtml'
 ));
 }
 
 
 Module.php:
 
 private function initLayout ($e)
 {
$this-eventManager-attach('dispatch', function($e)
 {
  
 $e-getViewModel()-setTemplate($e-getResult()-getVariable('layout'));
 }, -100);
 }
 
 
 But i get this exception:
 
 Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException'
 with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render
 template C:\www\zf2/template/default/example.phtml; resolver could not
 resolve to a file' in
 C:\www\zf2\system\vendor\zf2\library\Zend\View\Renderer\PhpRenderer.php on
 line 451
 
 What am i doing wrong? Or is there another way to do it?

Try to debug your full template path and check if that file is physically
there. It looks like your template path is wrong.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/bootstrap-event-to-change-template-tp4657144p4657145.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




[fw-general] Re: bootstrap event to change template

2012-09-26 Thread luk
MGP wrote
 file_exists(BASE_PATH . '/template/default/example.phtml')  return true
 and physically is there.
 Thats why i dont see whats wrong..

Try this code with a use of TemplatePathResolver, hope it helps:

class Module
{
// ...

public function init(ModuleManager $moduleManager)
{
$sharedEvents =
$moduleManager-getEventManager()-getSharedManager();
$sharedEvents-attach(__NAMESPACE__, 'dispatch', function($e) {
$serviceManager = $e-getApplication()-getServiceManager();
$templatePathResolver =
$serviceManager-get('Zend\View\Resolver\TemplatePathStack');
$templatePathResolver-setPaths(array(__DIR__ . '/view/blue'));
// here is your skin name

}, 100);
}
} 



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/bootstrap-event-to-change-template-tp4657144p4657171.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




[fw-general] Re: Documentation for adding parameter requirements via Zend_Application_Resource_Router

2012-09-26 Thread luk
Try to use Regex Route instead. It should do the job.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Documentation-for-adding-parameter-requirements-via-Zend-Application-Resource-Router-tp4657150p4657173.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




[fw-general] Re: ZF2: Service Manager - best practice

2012-09-22 Thread luk
developer10 wrote
 Here's a screenshot of my IDE showing my app tree-structure, with some
 arrows and actual question typed on it.
 http://screencast.com/t/1iJanCwXxnk
 
 For those not curious enough to open the above link, here's summary:
 
 I'm coding custom module Messenger, with currently 2 controllers present:
 - Home (welcome message)
 - Inbox (self-explanatory)
 
 The table name is called messenger, my model entity is MessengerEntity
 
 I want to have separate Service files but I'm unsure how should I name
 them.
 
 I went with this:
 /src
 /Messenger
 /Services
 /MessengerControllerFactory.php
 /MessengerServiceFactory.php
 /MessengerTableFactory.php
 
 
 
 Could it be said that the first part of the name (in my case: Messenger)
 is actually related to the name of the db table, not to the module or
 controller names?

In my opinion your naming is correct except the
MessengerControllerFactory.php. If that factory is supposed to be creating
all the Conrtollers within that Module then it i ok but otherwise youshould
have Inbox and Home Controller factories.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Service-Manager-best-practice-tp4657008p4657062.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




[fw-general] Re: [ZF2] Use Zend_Validate file in module.config.php

2012-09-21 Thread luk
Birzat wrote
 Thanks Luke,
 
 I choose the 2nd solution.
 
 How to do translation in the view in error message.
 
 I try : echo
 $this-translate($this-formElementErrors($form-get('mail')));
 
 But it doesn't work.
 
 Do you have a idea ?

I think that you don't need to do translate on form helper elements. The
Translate service should work there already as long as you have string
matches defined.
Also please make sure you are using the latest 2.0.1 version of ZF2 to make
sure all form view helpers are using defined Translate service. Please let
me know how you get on.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Use-Zend-Validate-file-in-module-config-php-tp4656964p4657006.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




[fw-general] Re: ZF2: Service Manager - best practice

2012-09-21 Thread luk
Ludwig Ruderstaller wrote
 Hi,
 
 After reading much about the Service Manager implementation in ZF2 and
 trying out a few things, I think I finally get the concept and the idea
 behind it.
 
 But please help me understand one thing.
 
 Imagine I have a medium size database with 10 entities. Along them are
 10 form definition.
 
 The input filter is described in the entity.
 
 in the service_manager I have a factory for each entity. (as the code is
 mostly the same the factories extend from an base entityFactory).
 then I have a factory for each Form (again extended by a base
 formFactory) which along other things inject the input filter from the
 entity.
 
 Is this really the right way?
 
 It seems extremly redundant to do this for each entity/form.
 There are abstract_factories which can work around this, but after what
 I have read, this is more of a fallback. Is this so? Can't I not just
 have a formFactory and a entityFactory? I would just have to implemnt
 the canCreateServiceWithName method to only target form respectively
 entity classes.
 
 Is there a downside to have multiple abstract factory classes?
 
 What is the best practice ?
 
 TIA
 Ludwig

In my opinion the best way is to use just one factory formFactory and a
entityFactory for each of your Forms and Entities. Obviously they would need
to handle some kind of identifier to know which object to create.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Service-Manager-best-practice-tp4657008p4657009.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




[fw-general] Re: Form element select error

2012-09-21 Thread luk
wilariz wrote
 luk.. now i have an error when I validate form..
 my error is :
 haystack option is mandatory
 
 trace:
 #0
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\Validator\InArray.php(175):
 Zend\Validator\InArray-getHaystack()
 #1
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\Validator\ValidatorChain.php(175):
 Zend\Validator\InArray-isValid('1', Array)
 #2
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\InputFilter\Input.php(263):
 Zend\Validator\ValidatorChain-isValid('1', Array)
 #3
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\InputFilter\BaseInputFilter.php(192):
 Zend\InputFilter\Input-isValid(Array)
 #4
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\Form\Form.php(420):
 Zend\InputFilter\BaseInputFilter-isValid()
 #5
 C:\xampp\htdocs\travelagency\module\Agencia\src\Agencia\Service\PaqueteService.php(41):
 Zend\Form\Form-isValid()
 #6
 C:\xampp\htdocs\travelagency\module\Backoffice\src\Backoffice\Controller\PaqueteController.php(97):
 Agencia\Service\PaqueteService-guardar(Array)
 #7
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(87):
 Backoffice\Controller\PaqueteController-nuevoAction()
 #8 [internal function]:
 Zend\Mvc\Controller\AbstractActionController-onDispatch(Object(Zend\Mvc\MvcEvent))
 #9
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(469):
 call_user_func(Array, Object(Zend\Mvc\MvcEvent))
 #10
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(209):
 Zend\EventManager\EventManager-triggerListeners('dispatch',
 Object(Zend\Mvc\MvcEvent), Object(Closure))
 #11
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractController.php(108):
 Zend\EventManager\EventManager-trigger('dispatch',
 Object(Zend\Mvc\MvcEvent), Object(Closure))
 #12
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php(114):
 Zend\Mvc\Controller\AbstractController-dispatch(Object(Zend\Http\PhpEnvironment\Request),
 Object(Zend\Http\PhpEnvironment\Response))
 #13 [internal function]:
 Zend\Mvc\DispatchListener-onDispatch(Object(Zend\Mvc\MvcEvent))
 #14
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(469):
 call_user_func(Array, Object(Zend\Mvc\MvcEvent))
 #15
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(209):
 Zend\EventManager\EventManager-triggerListeners('dispatch',
 Object(Zend\Mvc\MvcEvent), Object(Closure))
 #16
 C:\xampp\htdocs\travelagency\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(298):
 Zend\EventManager\EventManager-trigger('dispatch',
 Object(Zend\Mvc\MvcEvent), Object(Closure))
 #17 C:\xampp\htdocs\travelagency\public\index.php(12):
 Zend\Mvc\Application-run()
 #18 {main}
 
 how is the best way to validate a select element?


You can use required option and NotEmpty Validator as a simple case or
InArray Validator to do some more restrictive validation. It depends what
kind of requirements you've got and what exactly would you need to validate?



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Form-element-select-error-tp4656976p4657011.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




[fw-general] Re: Form element select error

2012-09-21 Thread luk




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Form-element-select-error-tp4656976p4657016.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




[fw-general] Re: Form element select error

2012-09-21 Thread luk
wilariz wrote
 Hi good day. well in this case select element should be load register
 from a databasetable 
 I have a form Register and my select element represents TypeRegister..
 what type of validation I should do?
 this is my select element:
  $this-add(array(
 'name' = '_subtipo',
 'type' = 'Zend\Form\Element\Select',
 'options' = array(
 'class' = 'input-medium',
 'value_options' = array(),
 'label' = 'Tipo:',
 )
 ));
 
 and here my simple validator:
$this-add(array(
 'name' = '_subtipo',
 'required' = true
 ));
 
 with this configuration my form fail..
 
 Thanks for answer !!

It will fail because there isn't any values in your select list and you set
this field as required which means it needs to pass not empty value.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Form-element-select-error-tp4656976p4657017.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




[fw-general] Re: Form element select error

2012-09-21 Thread luk
wilariz wrote
 you have reason.
 I'll explain you my application context:
 I'm making ddd design.
 I have n layers. in this case only use Application and Presentation
 layers:
 in my presentation layer I have  my controller classe where my action save
 I instance form, render and when is post.. I send form-Data() to my nex
 class SomeService this is in my application layer.. here I instance same
 form again and validate $form-isValid()
  but my specific case I populate in my presentation later but I didn't in
 my application service.. now I don't sure if is ok validate in my app
 service... because I should populate my select again.. and if I have
 several selects I'll call same amont to database :S I think I'll take a
 bad performance..
 
 I hope you understand my context.. what do you think about it?

OK simply it won't work beacuase you can't use isValid correctly on the
second Form that has not been submitted. From your description the flow you
have does not sound good. Is there any way to simplify what you are trying
to achieve?



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Form-element-select-error-tp4656976p4657026.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




[fw-general] Re: ZF2 create custom filter

2012-09-21 Thread luk
Ralf Eggert wrote
 Hi,
 
 in an entity I have the title column. A value could be:
 
   This is my stupid text with spécial chars!!!
 
 This entity has an url column. This should take the value from the title
 in a converted way like this:
 
   this-is-my-stupid-text-with-special-chars
 
 I think you know what I mean. Creating this filter is not the big deal.
 I only need to extend Zend\Filter\AbstractFilter or implement
 Zend\Filter\FilterInterface. But configuring the usage makes me think.
 
 I won't use the filter with a form. I want to use it in my service. When
 the title column is filled properly then the filter should be used to
 set thr url column.
 
 I could use the service manager to make instances of the filter
 available, but this sounds badly. Especially the injection of my filter
 to other classes sounds wrong.
 
 I could simply instantiate my filter in my service, but that sounds too
 simple.
 
 I guess I need to use the plugin manager or something but how?
 
 Please advise.
 
 Thanks and best regards,
 
 Ralf

I think in your case it does make sense to call that custom Filter in your
Service class as you've mentioned. I would do it this way.




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-create-custom-filter-tp4657029p4657031.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




[fw-general] Re: ZF2 create own library

2012-09-21 Thread luk
Ralf Eggert wrote
 Hi,
 
 within ZF1 I created my own library which was located in
 /library/Travello/ parallel to /library/Zend/. In my library I had
 additional filters or validators, general view helpers or extensions for
 some classes like the action controller or the response object.
 
 ZF2 now has modules. It is quite easy to add all these classes to a
 module. Stuff that I only need in my application can go to to the
 /module/Application/src/ directory.
 
 But how about stuff that I might want to use in different projects?
 
 a) Should this go to a module in the /vendor/ directory which has the
Module.php located at /vendor/travello/Library/Module.php
 
 b) Since the ZF2 is no module (Module.php is missing), I could build
my extension in the same way that
/vendor/zendframework/zendframework/ is set up?
 
 I think I would prefer a). What do others think about this?
 
 Regards,
 
 Ralf

My recommendation is the first option you've pointed out. It''s very
flexible in terms of reusing stuff.
I'm using sub namespaces for my vendor common Modules. I have it structured
like that: vendor/BS/ModuleName1, vendor/BS/ModuleName2, etc.
In my application config I'm loading them in this way:
return array(
'modules' = array(
'Test',
'BS\ModuleName1', // loading module from vendor when no config
override is needed
'BS\ModuleName2', // loading module from vendor...
'ModuleName2', // ...from /modules folder to override settings of
the 'BS\ModuleName2'
'Application',
),
'module_listener_options' = array(
'config_glob_paths'= array(
'config/autoload/{,*.}{global,local}.php',
),
'module_paths' = array(
'./module',
'./vendor',
),
),
);





-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-create-own-library-tp4657032p4657034.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




[fw-general] Re: ZF2 create custom filter

2012-09-21 Thread luk
Ralf Eggert wrote
 Hi Luke,
 
 I think in your case it does make sense to call that custom Filter in
 your
 Service class as you've mentioned. I would do it this way.
 
 A couple of minutes ago I found Zend\Filter\StaticFilter which uses in
 instance of Zend\Filter\FilterPluginManager. I am curious how to add my
 custom filters to this FilterPluginManager. It should work like this:
 
 StaticFilter::getPluginManager()-setInvokableClass(
 'stringtourl', 'Application\Filter\StringToUrl'
 );
 
 Again the big question is where to add this line?
 
 - Module::onBootstrap()
 - a listener
 - trigger an event to add this
 
 Regards,
 
 Ralf

Hi Ralf,
I was thinking that the other option would be to set that custom class in
invokables in Service Config and then retrieve it and set in your service
factory.




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-create-custom-filter-tp4657029p4657040.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




[fw-general] Re: ZF2 create own library

2012-09-21 Thread luk
Ralf Eggert wrote
 I created /vendor/ralfeggert/travello/ now which holds a simple
 Module.php which just outputs a text to check the module loading.
 
 My /config/application.config.php looks like this:
 
 --
 return array(
 'modules' = array(
 'Application',
 'ralfeggert\travello',
 ),
 'module_listener_options' = array(
 'config_glob_paths'= array(
 'config/autoload/{,*.}{global,local}.php',
 ),
 'module_paths' = array(
 './module',
 './vendor',
 ),
 ),
 );
 --
 
 That does not work.
 
   Fatal error: Uncaught exception 'Zend\ModuleManager\Exception
   \RuntimeException' with message 'Module (ralfeggert\travello)
   could not be initialized.'
 
 Switching the \ to a / does not help either. But this does help:
 
 --
 return array(
 'modules' = array(
 'Application',
 'travello',
 ),
 'module_listener_options' = array(
 'config_glob_paths'= array(
 'config/autoload/{,*.}{global,local}.php',
 ),
 'module_paths' = array(
 './module',
 './vendor',
 './vendor/ralfeggert',
 ),
 ),
 );
 --
 
 It works, but feels wrong. What am I missing?

The solution I've recommended to you won't follow the way that Modules do
work. Your Module would need to include that sub namespace bit in Module.php
class, like:
namespace BS\Page;

and other resources being loaded, for ie. Controllers:
'controllers' = array(
'invokables' = array(
'Page\Controller\Page' = 'BS\Page\Controller\PageController',
),
),

Other solution which may be simpler for you is to use another, standard
autoloader just for this kind of modules.




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-create-own-library-tp4657032p4657044.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




[fw-general] Re: ZF2 How to change template directory

2012-09-21 Thread luk
Distrust wrote
 I want to setup the following skin directory structure:
 
 module/Application/view/
- default
- application
- index
- index.phtml
- test
- index.phtml
- something-else.phtml
- blue
- application
- index
- index.phtml
- test
- index.phtml
- something-else.phtml
- red
- application
- index
- index.phtml
- test
- index.phtml
- something-else.phtml
 
 I know that I can change template in this way:
 $viewModel-setTemplate($templatePath);
 but when I try to change template to
 /blue/application/test/something-else in the init() method in the Module
 class then I'm getting for example this error:
 Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException'
 with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render
 template application/test/something-else; resolver could not resolve to
 a file'.
 
 My code:
 // ...
 
 class Module
 {
 // ...
 
 public function init(ModuleManager $moduleManager)
 {
 $sharedEvents =
 $moduleManager-getEventManager()-getSharedManager();
 $sharedEvents-attach(__NAMESPACE__, 'dispatch', function($e) {
 
 $controller = $e-getTarget();
 
 $skinName = 'blue';
 $templatePath = $skinName .
 '/application/test/something-else';
 
 $viewModel = $e-getViewModel();
 $viewModel-setTemplate($templatePath);
 
 }, 100);
 }
 }
 
 What I'm doing wrong?
 I also tried to use setLayout() method, but with similar result.

Hi, setTemplate and setLayout functions change the default layout template
that is being used. Clearly what you're trying to achieve here is to change
default views path and you can easily do so by overriding your
template_path_stack. Try this:

class Module
{
// ...

public function init(ModuleManager $moduleManager)
{
$sharedEvents =
$moduleManager-getEventManager()-getSharedManager();
$sharedEvents-attach(__NAMESPACE__, 'dispatch', function($e) {
$serviceManager = $e-getApplication()-getServiceManager();
$templatePathResolver =
$serviceManager-get('Zend\View\Resolver\TemplatePathStack');
$templatePathResolver-setPaths(array(__DIR__ . '/view/blue'));
// here is your skin name

}, 100);
}
}



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-How-to-change-template-directory-tp4656995p4657052.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




[fw-general] Re: [ZF2] Switching layouts between modules.

2012-09-20 Thread luk
Razorblade wrote
 Hi everyone, 
 I still have the same problem also with the stable release.
 
 Any solution?
 
 Thanks

Did you try this solution by Evan?
http://akrabat.com/zend-framework-2/module-specific-layouts-in-zf2/
http://akrabat.com/zend-framework-2/module-specific-layouts-in-zf2/  



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Switching-layouts-between-modules-tp4190088p4656974.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




[fw-general] Re: Form element select error

2012-09-20 Thread luk
wilariz wrote
 Hi. I'm trying to create a form with a select element... but when I want
 render I have a message error.
 
 this is my definition: 
 $this-add(array(
 'name' = '_subtipo',
 'attributes' = array(
 'type' = 'select',
 'class' = 'input-medium',
 'options' = array('man'=1,'woman'=2)
 ),
 'options' = array(
 'label' = 'Tipo:',
 ),
 ));
 
 and this is my error :
  Uncaught exception 'Zend\Form\Exception\InvalidArgumentException' with
 message 'Zend\Form\View\Helper\FormSelect::render requires that the
 element is of type Zend\Form\Element\Select'
 
 My form work fine because I have other elements that render good.

Try this:
$this-add(array(
'type' = 'Zend\Form\Element\Select',
'name' = '_subtipo',
'options' = array(
'label' = 'Tipo:',
'class' = 'input-medium',
'value_options' = array('man'=1,'woman'=2)
),
));



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Form-element-select-error-tp4656976p4656978.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




[fw-general] Re: Zend Navigation with Translations

2012-09-20 Thread luk
frigozend wrote
 I would like to create a MENU with different items in different languages
 (Spanish and English), using Zend_translage and Zend_navigation
 components. 
 
 
 Until now , I have achieved:
 
 Menu works in only one language.
 All contents in my layouts or views can be translated to all languages.
 
 My bootstrap file:
 

 
function _initSetTranslations()
 {
 $this-bootstrap('layout');
 $layout = $this-getResource('layout');
 $view = $layout-getView();
 
 
 $english = array('documental' = 'The Documentary','equipo' = 'The
 Team','productores' = 'The Producers');
 $spanish = array('documental' = 'El Documental','equipo' = 'El
 Equipo','productores' = 'Los Productores');
 
 
 $translate = new Zend_Translate(array('adapter' = 'array','content' =
 $english,'locale'  = 'en'));
 $translate-addTranslation(array('content' = $spanish, 'locale' =
 'es'));
 
 
  $view-translate = $translate;  
 
 }
 
 
   protected function _initNavigation()
   {
 
   
 
   $layout = $this-getResource('layout');
   $view = $layout-getView();
 
 
$pages = array(
   array('controller'= 'index','action' = 'documental','label'=
 $view-translate-_(documental),),  
   

   array('controller'= 'index','action' = 'equipo','label'=
 $view-translate-_('equipo'),),
   array('controller'= 'index','action' = 'productores','label'=
 $view-translate-_(productores),),
   );
 
 $translate = new Zend_Navigation($pages);
 
 
 
   $view-navigation($translate);  
 
 
 
   }   
 
 }
 
 In my Layout:
 
   $this-translate-setLocale('es'); 
   
   echo $this-navigation()-menu(); 
 
 
 
 
 It shows the menu Items always in English, although 'es' is selected. Does
 anybody know how to change the language in the menu items?

Try to set your Locale and Translations into Registry on Bootstrap like in
the sample below.
Then construct your Navigation in your default Controller or Plugin. Once
you call echo $this-navigation()-menu(); in your view then you should be
able to see correct translations.

protected function _initLocale()
  {
$session = new Zend_Session_Namespace('square.l10n');
if ($session-locale) {
  $locale = new Zend_Locale($session-locale);
}

if (!isset($locale)) {
  try {
$locale = new Zend_Locale('browser');
  } catch (Zend_Locale_Exception $e) {
$locale = new Zend_Locale('en_GB');
  }
}

$registry = Zend_Registry::getInstance();
$registry-set('Zend_Locale', $locale);
  }


  protected function _initTranslate()
  {
$translate = new Zend_Translate('array', APPLICATION_PATH .
'/../languages/',
  null, array('scan' = Zend_Translate::LOCALE_FILENAME,
'disableNotices' = 1));
$registry = Zend_Registry::getInstance();
$registry-set('Zend_Translate', $translate);
  }




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-with-Translations-tp4656968p4656979.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




[fw-general] Re: [ZF2] Use Zend_Validate file in module.config.php

2012-09-20 Thread luk
Birzat wrote
 Thanks for your answer.
 
 Buti is it possible to use php files as Zend_Validate.php (content
 translate of the errors messages for form).
 
 In your example de type is 
*
 'type' = 'gettext', 
*
 
 I would like to translate the erros message after submit form with the
 Zend_Validate.php file.

You can try this sample, it works for me but you would need then always
overwrite base_dir for other languages.
'translator' = array(
'locale' = 'Zend_Validate', // make sure this file is in correct
path
'translation_file_patterns' = array(
array(
'type' = 'phparray',
'base_dir' = __DIR__ . '/../language/fr',
'pattern'  = '%s.php',
),
),
),

Better and recommended solution would be:
'translator' = array(
'locale' = 'fr_FR',
'translation_file_patterns' = array(
array(
'type' = 'phparray',
'base_dir' = __DIR__ . '/../language',
'pattern'  = '%s.php',
),
),
),




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Use-Zend-Validate-file-in-module-config-php-tp4656964p4656980.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




[fw-general] Re: AW: WG: [ZF2][Doctrine2] Autogeneration of entity classes

2012-09-20 Thread luk
tridem wrote
 Hi Luke,
 
 that is my problem. I recently started with ZF2 and followed this
 tutorial:
 
 http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/

You should not be following this tutorial for Doctrine integration. The ZF2
version that time was far away from current stable version.

 

tridem wrote
 Even the github at
 
 https://github.com/doctrine/DoctrineORMModule
 
 only states:
 
 The module depends on  lt;https://github.com/doctrine/ormgt; Doctrine
 ORM
 2.3.*,  lt;https://github.com/doctrine/dbalgt; Doctrine DBAL 2.3.*,
 lt;https://github.com/doctrine/migrationsgt; Doctrine Migrations. You
 have to
 download/install those packages and have them autoloaded.
 
 Sorry, but I couldn't find a hint where to put this autoloading. Is there
 a
 specific file in should put it in for global access, should it be added to
 a
 module only config or
 
 by setting an include path inside the virtual host or my index.php and
 how?

I'm not a fan of Doctrine personally but I recommend you to try looking
here:
https://github.com/doctrine/DoctrineModule
https://github.com/doctrine/DoctrineModule  

and again here:
https://github.com/doctrine/DoctrineORMModule
https://github.com/doctrine/DoctrineORMModule  

and as Marco pointed out use Composer for installing those Modules.





-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/WG-ZF2-Doctrine2-Autogeneration-of-entity-classes-tp4656940p4656981.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




[fw-general] Re: ZF2 Doing something before calling the controller action

2012-09-19 Thread luk
Distrust wrote
 What can I do to initialize (do some stuff) before calling the controller
 action?
 Zend have init() function, but Zend 2 doesn't. So that (for example):
 
 class BaseController extends AbstractActionController
 {
   protected $settings_table;
   protected $settings;
 
   public function __construct()
   {
   $this-settings = $this-getSettingsTable()-fetchAll();
   }
 
   public function getSettingsTable()
   {
   if (!$this-settings_table)
   {
   $sm = $this-getServiceLocator();
   $this-settings_table = 
 $sm-get('Application\Model\SettingsTable');
   }
 
   return $this-settings_table;
   }
 }
 
 class TestController extends BaseController
 {
   // ...
 
   public function showSettingsAction()
   {
   return new ViewModel(array(
   'settings' = $this-settings
   ));
   }
 }
 
 won't work, because the objects have not been created yet.

To achieve that you would need to listen on the dispatch Event with high
priority that is being executed prior to any Contoller logic. Please try
this code in your Module.php.

namespace ModuleName;

use ModuleNama\Controller\MyController;
use Zend\EventManager\EventManagerInterface;

class Module
{

public function getControllerConfig()
{
return array(
'factories'  = array(
'ModuleName\Controller\MyController' = 
function($sm) {
$events = 
$sm-getServiceLocator()-get('EventManager');
$controller = new MyController();
$events-attach('dispatch', function 
($e) use ($controller) {
$request = $e-getRequest();
$method  = 
$request-getMethod();

// your own initialization 
logic here
if 
($controller-params()-fromRoute('paramName', false)) {
return;
}
}, 100); // run before controller 
action logic

$controller-setEventManager($events);
return $controller;
}
),
);
}
}




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Doing-something-before-calling-the-controller-action-tp4656922p4656923.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




[fw-general] Re: ZF2 Doing something before calling the controller action

2012-09-19 Thread luk
Distrust wrote
 
 Matus Zeman wrote
 Why can't you simply implement it inside of  showSettingsAction() method?
 Because I need a universal method to initialize various elements (before
 action), without duplicating my code in every other controller action.
 Settings were just an example.

For universal solution you may want to try this one, it will work for all
Controllers within single Module:
class Module
{

// Evan's changing layout for specific module only
public function init(ModuleManager $moduleManager) {
$sharedEvents =
$moduleManager-getEventManager()-getSharedManager();
$sharedEvents-attach(__NAMESPACE__, 'dispatch', function($e) {
$controller = $e-getTarget();
// do your stuff with controller
}, 100);
}
}



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Doing-something-before-calling-the-controller-action-tp4656922p4656934.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




[fw-general] Re: [ZF2][Doctrine2] Autogeneration of entity classes

2012-09-19 Thread luk
Razorblade wrote
 As I commented at the end of that article, does anybody know if there is a
 way to autogenerate entity classes? It would be a long and repetitive work
 to create entity classes by hand with table of more than hundred columns.

In my opinion your question is more related to Doctrine itself. You should
be able to find CLI PHP script within Doctrine to generate Entity classes.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Doctrine2-Autogeneration-of-entity-classes-tp4656924p4656935.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




[fw-general] Re: ZF2 How to dump all sql queries executed by Zend?

2012-09-19 Thread luk
Distrust wrote
 In CakePHP I can use (in a view):
 $this-element('sql_dump');
 
 But how to do something similar in Zend 2.0? I want to preview all the
 queries (generated by the script) in the exact form in which they are sent
 to the database. I'm using AbstractTableGateway.

In Zend1 you could use Query Profiler to have all the SQL queries output in
the Browser's console log or on the screen. Currently ZF2 does not provide
that Profiler plugin yet. You could try to use this Module though:
https://github.com/bjyoungblood/BjyProfiler
https://github.com/bjyoungblood/BjyProfiler  





-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-How-to-dump-all-sql-queries-executed-by-Zend-tp4656932p4656937.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




[fw-general] Re: ZF2 JqGrid integration

2012-09-19 Thread luk
gzamboni wrote
 Hi,
 i start training and learning zf2 with the tuttorial on the web site,
 now i want to integrate a jqGrid and i need to retrieve a json string from
 the view model
 
 my code example:
*
  public function indexAction()
 {
 
   return new ViewModel(array( 
 |
'albums' = $this-getAlbumTable()-fetchAll(),|---
 view model data
 ));  
*
  |
  
 -
 i found on akrabat site the json model strategy and i add this JsonModel:
 
 
   
*
   $result = new JsonModel(array(
   
'albums' = $this-getAlbumTable()-fetchAll(),
'success'=true,

 
 )); 
 echo $result;
*
 
 but it returns a json string empty xD
 im really noob in knowledge of zf but i'll try to do my best :D
 
 Wait for response , 
 regards.

Did you try to register JSON rendering strategy first as per docs in
Zend\View quickstart component?




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-JqGrid-integration-tp4656925p4656939.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




[fw-general] Re: WG: [ZF2][Doctrine2] Autogeneration of entity classes

2012-09-19 Thread luk
tridem wrote
 A short question:
 
 Where do I have to set the autoloading for Doctrine since I am getting
 this
 error:
 
 Fatal error: Class 'Doctrine\Common\Annotations\AnnotationRegistry' not
 found in.

Please make sure that your Doctrine lib is properly integrated with Zend
Framework. For me it looks like it isn't.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/WG-ZF2-Doctrine2-Autogeneration-of-entity-classes-tp4656940p4656941.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




[fw-general] Re: ZF2 JqGrid integration

2012-09-19 Thread luk
gzamboni wrote
 yes i do but the problem is :
 i solved that but my problem now is to pass data from index.phtml to the
 indexaction controller.
 is that possible?
 can you show me it with a simple example?
 thz again.

You're getting an empty array because your albums var passed to the view is
a ResultSet object. You would need to extract from it an array of Album
Models first.
Try something like that:
   foreach ($this-getAlbumTable()-fetchAll() as $album) {
$albums[] = $album;
}

$result = new JsonModel(array(
'albums' = $albums,
'success'=true,
));
return $result;




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-JqGrid-integration-tp4656925p4656951.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




[fw-general] Re: ZF2 per route (or module) configuration

2012-09-19 Thread luk
ghola wrote
 Maybe my initial question was not very good at conveying the actual issue.
 Bootstrapping can be a resource intensive process. Bootstrapping modules
 that won't be used for the current request is plain inefficient. Even if
 the modules are more granular like you mention, it doesn't mean that they
 should all load for each request.
 
 In ZF1 this indiscriminate boostraping was an issue too. As such i
 implemented a second boostraping layer after routing was performed because
 at that time i could obtain the name of the module that was being loaded
 (similar to this:
 http://binarykitten.com/zend-framework/296-active-module-config-v2.html).
 I had hoped that this was somehow solved in ZF2 since it's developers seem
 more preoccupied with it's performance than in ZF1 (one of the actual
 reasons for the rewrite). So in my mind, one solution was be to allow per
 route configuration since routing determines the actual module that is
 going to be used (although i agree that it might not be the brightest of
 ideas).

Ok now I get it what you meant.

I think you've misunderstood the concept of ZF2 architecture in terms of
using resources. Loading modules or making them active in application config
means loading modules configurations only. These btw can be easily cached
after the first request.

ZF2 is event driven which means that by using Dependency Injection,  Event
and Service Managers and some of your custom factories in each of your
Module's config you are creating mappings to say when and where your
resources(like Plugins, Controllers, Helpers or Models) are injected and
instantiated at the time they are used. That in fact is happening on certain
routes that you setup as well as you know.





-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-per-route-or-module-configuration-tp4656844p4656953.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




[fw-general] Re: Event driven / Wigets / Form generation

2012-09-18 Thread luk
nuxwin wrote
 I am facing a small problem:
 
  I've two modules:
 
 DomainsManager
 DnsManager (Optional module)
 
 The first module provides an action (addDomain) that allows an user to add
 a new domain via a form.
 
 I want be able to extend that form with a partial view/form pulled from
 the DnsManager module (if activated) to allow the user to specify whether
 or not the DNS zone for that domain must be generated.
 
 I'm thinking about a specific event listener (provided by the DnsManager
 module) to listen on the 'onAddDomain' event (provided the DomainManager
 module) but I'm not sure it's the good way to do. If I do that way, that
 mean that for each request, I will have to register that listener ?,
 even if the current route do not match for an action provided by the
 DomainManager module ?
 
 To resume, what I want do is a kind of widget system but I want avoid too
 much hard dependencies between the modules. I would also avoid to use the
 forward plugin into my module controllers since that involve hard
 dependencies.

You could do a check for loaded/active Modules on loadModules.post event in
your Module.php class firstly. Then in your getControllerConfig you can use
a factory and ServiceManager to inject appropriate Form based on the Modules
check result. Your DnsManager Form can extend a DomainsManager one or you
could just add another fieldset to the DomainsManager Form.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Event-driven-Wigets-Form-generation-tp4656890p4656902.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




[fw-general] Re: zf2 form validation

2012-09-18 Thread luk
poashoas wrote
 So here I go, I have a form, I tried to tell the field it has a validator
 or something,
 and I got no idea where to start if I wanna show a message that the email
 address ain't valid.
 
 So far I have a form working:
*
 The controller:
*
 
 public function indexAction ()
 {
 $form = new LoginForm();
 return array('form' = $form);
 }
 
 class Login extends Form
 {
 public function __construct ()
 {
parent::__construct('myform');
 
$this-setAttributes(array(
   'id' = 'loginForm',
   'method' = 'post'
))
-add(array(
'name' = 'username',
'attributes' = array(
'type' = 'text',
),
   'filters' = array(
  array('StringTrim')
   ),
   'validators' = array(
  array('name' = 'EmailAddress')
   ),
   'options' = array(
'required' = true,
'label'= 'Email'
   )
))
-add(array(
 'name' = 'submit',
 'attributes' = array(
 'type' = 'submit',
 'value' = 'Login'
),
));
 }
 }
*
 The view:
*
 
 echo $this-form()-openTag($form);
 echo $this-formRow($form-get('username'));
 echo $this-formSubmit($form-get('submit'));
 echo $this-form()-closeTag($form);

Try this code for your Email address form element:

$this-add(array(
'name' = 'username',
'options' = array(
'label' = 'Email',
),
'attributes' = array(
'required' = 'required'
),
'filters' = array(
array('name' = 'StringTrim'),
),
'validators' = array(
array(
'name' = 'EmailAddress',
'options' = array(
'messages' = array(
\Zend\Validator\EmailAddress::INVALID_FORMAT =
'Email address format is invalid'
)
)
)
)
));

The above will first apply a filter StringTrim which will remove empty
spaces and then it will validate an Email address and override a standard
message for invalid format. You can remove that option if you want to use a
standard message. For more information about forms you can read here:
http://www.michaelgallego.fr/blog/?p=190
http://www.michaelgallego.fr/blog/?p=190  



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/zf2-form-validation-tp4656907p4656911.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




[fw-general] Re: ZF2 query something

2012-09-17 Thread luk
It is not a good practice to run a query directly inside your class. I
recommend you to fit your query in the model and create a mapper which can
execute it. Then setup your mapper to be injected in your class, where you
require it. If you need any more details please ask.


poashoas wrote
 
 I just want to run a simple query inside my class.
 Lets say something like:
 
 $query = SELECT blah FROM test WHERE 1=1;
 $result = execute($query);
 
 class PermissionsAcl extends AbstractPlugin {
   protected $sesscontainer ;
 
 private function getSessContainer()
 {
 if (!$this-sesscontainer) {
 $this-sesscontainer = new SessionContainer('zftutorial');
 }
 return $this-sesscontainer;
 }
 
 public function doAuthorization($e)
 {
  $Listacl = new Whitelist();
  $test = $Listacl-getWhitelist();
 $cache = StorageFactory::factory(array(
 'adapter' = array(
 'name' = 'Filesystem',
 'options' = array(
 'cacheDir' = 'data/cache',//__DIR__ .
 '/../../../../../../
 ),
 ),
 'plugins' = array('serializer'),
 ));
 $cache-setItem('testing-array', array('hello' = 'test'));
 $array = $cache-getItem('testing-array');
 print_r($array);
 //setting ACL...
 $acl = new Acl();
 //add role ..
 $acl-addRole(new Role('anonymous'));
 $acl-addRole(new Role('user'),  'anonymous');
 $acl-addRole(new Role('admin'), 'user');
 
 $acl-addResource(new Resource('Application'));
  //   $acl-addResource(new Resource('Login'));
 
 $acl-allow('anonymous', 'Application', 'view');
   //  $acl-allow('anonymous', 'Login', 'view');
 
 $acl-allow('anonymous',
 array('Application'),
 array('view')
 );
 
 $routeMatch = $e-getRouteMatch();
 $namespaceController =  $routeMatch-getParam('controller');
 $namespace =  str_replace('\Controller\\' .
 ucfirst($routeMatch-getParam('action')),'',$namespaceController);
 
 $role = (! $this-getSessContainer()-role ) ? 'anonymous' :
 $this-getSessContainer()-role;
 if ( ! $acl-isAllowed($role, $namespace, 'view')){
 $router = $e-getRouter();
 //$url= $router-assemble(array(), array('name' =
 'Login/auth'));
 
 $response = $e-getResponse();
 $response-setStatusCode(302);
 //redirect to login route...
// $response-getHeaders()-addHeaderLine('Location', $url);
 }
 }
 }
 




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-query-something-tp4656840p4656865.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




[fw-general] Re: Custom Library

2012-09-17 Thread luk
Definitely you called wrong class again below:
Class 'Pixiebox\Resources\Whitelist\ListAcl' not found that was not your
class, it was:
Pixiebox\Resources\Acl\Whitelist as Whitelist

That's my index.php:

chdir(dirname(__DIR__));

// Setup autoloading
include 'init_autoloader.php';

Zend\Loader\AutoloaderFactory::factory(array(
'Zend\Loader\StandardAutoloader' = array(
'namespaces' = array(
'Pixiebox' = 'vendor/Pixiebox',
)
)
));

use Pixiebox\Resources\Acl\Whitelist as Whitelist,
Zend\Mvc\Controller\Plugin\AbstractPlugin;

echo Whitelist::getWhitelist();

I made getWhitelist method static and returned simple output, and guess
what? it is working as expected...



poashoas wrote
 
 Still not working Class 'Pixiebox\Resources\Whitelist\ListAcl' not
 found
 ...
 Should I make a classmap or something
 When I am typing it in my Netbeans it is recognizing my class in the file
 and stuff with autosuggest still no success
 




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Custom-Library-tp4656831p4656834.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




[fw-general] Re: ZF2 per route (or module) configuration

2012-09-17 Thread luk
This isn't going to work that way. You can configure your view manager's
template_map to alias different templates names in each of modules you are
using then for sure you won't have them overriden.

Something like:
in FrontendModule:
'config' = array(
  'view_manager' = array(
'template_map' = array(
  'frontendLayout' = __DIR__ . '/../view/layout/layout.phtml'
)
  )
)

in BackendModule:
'config' = array(
  'view_manager' = array(
'template_map' = array(
  'backendLayout' = __DIR__ . '/../view/layout/layout.phtml'
)
  )
)

But as I mentioned in my prev. post personally I would not consider frontend
and backend as modules that do everything. At the end of the day it's all up
to you and definitely with ZF2 you can still achieve what you want really.


ghola wrote
 
 A more elegant alternative which would in fact enable true per route based
 configuration would be to be able to specify a per route config. Like this
 (as part of a module.config.php file):
 
 'router' = array(
   'routes' = array(
   'backend' = array(
   'type' = 'segment',
   'options' = array(
   'route' = '/backend[/:controller[/:action]]',
   'constraints' = array(
   'controller' = 
 '[a-zA-Z][a-zA-Z0-9_-]*',
   'action' = '[a-zA-Z][a-zA-Z0-9_-]*'
   ),
   'defaults' = array(
   'controller' = 
 'Backend\Controller\Index',
   'action' = 'index'
   ),
   'config' = array(
   'view_manager' = array(
   'template_map' = array(
   'layout/layout' = 
 __DIR__ . '/../view/layout/layout.phtml'
   )
   )
   )
   )
   )
   )
 )
 
 Notice the 'config' key.
 




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-per-route-or-module-configuration-tp4656844p4656880.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




[fw-general] Re: Getting started: library installed in zendframework/zendframework, vendor/ZF2 is empty dir

2012-09-17 Thread luk

debussy007 wrote
 
 But then how does the application find the library?
 In init_autoloader.php I have the following:
 
 /if (getenv('ZF2_PATH')) {   // Support for ZF2_PATH environment
 variable or git submodule
 $zf2Path = getenv('ZF2_PATH');
 } elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive
 value
 $zf2Path = get_cfg_var('zf2_path');
 } *elseif (is_dir('vendor/ZF2/library')) {
 $zf2Path = 'vendor/ZF2/library';
 }*/
 

You have many options here to sort this out.
Firstly you can set your environment variable to point to the
vendor/zendframework/zendframework library folder.
Secondly you can edit last elseif statement above to reflect your
vendor/zendframework/zendframework lib.
You could also install SkeletonApp as git submodule then it will work out of
the box. It's all up to you really.

If you're after using ZF2 lbrary only without installing any 3rd parties you
could also use this:

require_once 'vendor/Zend/Loader/AutoloaderFactory.php';

Zend\Loader\AutoloaderFactory::factory(array(
'Zend\Loader\StandardAutoloader' = array(
'autoregister_zf' = true
)
));

and copyZend folder directly inside the vendor, like: vendor/Zend



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Getting-started-library-installed-in-zendframework-zendframework-vendor-ZF2-is-empty-dir-tp4656876p4656881.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




[fw-general] Re: ZF2 current date

2012-09-14 Thread luk
I would say, using ZF2 does not explain you to not use PHP. ;)


manisha wrote
 
 So does it mean we have to use implicitly PHP's DateTime class while
 working with Zend framwork 2 ?
 




-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-current-date-tp4656810p4656826.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