bedezign\yii2\audit\Audit::findModuleIdentifier PHP Méthode

findModuleIdentifier() public static méthode

public static findModuleIdentifier ( ) : integer | null | string
Résultat integer | null | string
    public static function findModuleIdentifier()
    {
        foreach (Yii::$app->modules as $name => $module) {
            $class = null;
            if (is_string($module)) {
                $class = $module;
            } elseif (is_array($module)) {
                if (isset($module['class'])) {
                    $class = $module['class'];
                }
            } else {
                /** @var Module $module */
                $class = $module::className();
            }
            $parts = explode('\\', $class);
            if ($class && strtolower(end($parts)) == 'audit') {
                return $name;
            }
        }
        return null;
    }

Usage Example

 /**
  * Cleanup the Audit data
  *
  * @return int|void
  */
 public function actionCleanup()
 {
     /** @var Audit $audit */
     $audit = Yii::$app->getModule(Audit::findModuleIdentifier());
     $panels = $this->panels !== null ? explode(',', $this->panels) : array_keys($audit->panels);
     // summary
     $this->preCleanupSummary($this->entry, $panels, $this->age);
     // confirm
     if ($this->confirm('Cleanup the above data?')) {
         // cleanup panels
         foreach ($panels as $id) {
             if (!$this->cleanupPanel($id, $this->age)) {
                 $this->stdout("\nCleanup failed. The rest of the cleanups are canceled.\n", Console::FG_RED);
                 return self::EXIT_CODE_ERROR;
             }
         }
         // cleanup audit_entry
         if ($this->entry) {
             if (!$this->cleanupEntry($this->age)) {
                 $this->stdout("\nCleanup failed.\n", Console::FG_RED);
                 return self::EXIT_CODE_ERROR;
             }
         }
         // success!
         $this->stdout("\nCleanup was successful.\n", Console::FG_GREEN);
     }
     return self::EXIT_CODE_NORMAL;
 }
All Usage Examples Of bedezign\yii2\audit\Audit::findModuleIdentifier