ACL im ZF auf Actionebene

Tags:, , | Blog | Geschrieben von toocan | Kommentieren
Mrz 08 03

Nun, da ich schon einige Male gefragt wurde, wie am besten zu lösen (wobei ich nicht sagen kann, ob dies die beste Lösung ist), poste ich mal ‘unsere’ Möglichkeit:


[...]
$acl_resources = array();
 foreach ($this->getFrontController()->getControllerDirectory() as $module => $cntrl_path)
 {
    $files = scandir($cntrl_path);
    foreach ($files as $file)
    {
        if (preg_match('/^([\\w]*)Controller\.php$/i',$file,$hits))
        {
          $classPrefix = ($module == 'default') ? '' : ucfirst($module).'_';
          $className = $classPrefix.$hits[1].'Controller';
          require_once($cntrl_path.DIRECTORY_SEPARATOR.$file);
          if (class_exists($className))
          {
            $refl_class = new ReflectionClass($className);
            foreach ($refl_class->getMethods() as $refl_method)
            {
                if (preg_match('/^([\\w]*)Action$/i',(string) $refl_method->getName(),$matches))
                {
                    $acl_resources[$refl_method->getDeclaringClass()->getName()][] = array(
                                                                                           'action'         => $matches[0],
                                                                                           'action_short'   => strtolower($matches[1])
                                                                                           );
                }
            }
          }
        }
    }
}
[...]

Wenn’s gefällt, viel Spass – ansonsten bin ich über Kommentare/ Kritik sehr erfreut.

Gruß tucci


« (P)Fund(s)stück der Woche (KW10/2008)Wordpress, Polyglot und Templates »

Keine Kommentare

Kommentieren | Diskussion verfolgen | Trackback URI


Sag deine Meinung

Du kannst diese HTML-Tags benutzen:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

* Diese Felder müssen ausgefüllt werden.




Safari hates me