src/Kunstmaan/PagePartBundle/Helper/Services/PagePartCreatorService.php
public function getCreatorArgumentsForPagePartAndProperties($pagePartClassName, array $setters = null)
    {
        return function () use ($pagePartClassName, $setters) {
            $pp = new $pagePartClassName();

            if (!is_null($setters)) {
                foreach ($setters as $setter => $value) {
                    call_user_func(array($pp, $setter), $value);
                }
            }

            return $pp;
        };
    }
public function getCreatorArgumentsForPagePartAndProperties($pagePartClassName, array $setters = null)
    {
        return function () use ($pagePartClassName, $setters) {
            $pp = new $pagePartClassName();

            if (!is_null($setters)) {
                foreach ($setters as $setter => $value) {
                    call_user_func(array($pp, $setter), $value);
                }
            }

            return $pp;
        };
    }
public function getCreatorArgumentsForPagePartAndProperties ( $ pagePartClassName , array $ setters = null ) { return function ( ) use ( $ pagePartClassName , $ setters ) { $ pp = new $ pagePartClassName ( ) ; if ( ! is_null ( $ setters ) ) { foreach ( $ setters as $ setter => $ value ) { call_user_func ( array ( $ pp , $ setter ) , $ value ) ; } } return $ pp ; } ; }
A helper function to express what pagepart you want.

It just accepts a classname and an array of setter functions with their requested values.

It'll return an anonymous function which instantiates the pagepart.

@param string $pagePartClassName the full class name of the pagepart you want to instantiate
@param array  $setters           An array of setternames and their values. array('setName' => 'Kim', 'isDeveloper' => true)

@return callable the function that will instantiate a pagepart
A helper function to express what pagepart you want .