yii\helpers\BaseFileHelper::filterPath PHP Method

filterPath() public static method

Checks if the given file path satisfies the filtering options.
public static filterPath ( string $path, array $options ) : boolean
$path string the path of the file or directory to be checked
$options array the filtering options. See [[findFiles()]] for explanations of the supported options.
return boolean whether the file or directory satisfies the filtering options.
    public static function filterPath($path, $options)
    {
        if (isset($options['filter'])) {
            $result = call_user_func($options['filter'], $path);
            if (is_bool($result)) {
                return $result;
            }
        }
        if (empty($options['except']) && empty($options['only'])) {
            return true;
        }
        $path = str_replace('\\', '/', $path);
        if (!empty($options['except'])) {
            if (($except = self::lastExcludeMatchingFromList($options['basePath'], $path, $options['except'])) !== null) {
                return $except['flags'] & self::PATTERN_NEGATIVE;
            }
        }
        if (!empty($options['only']) && !is_dir($path)) {
            if (($except = self::lastExcludeMatchingFromList($options['basePath'], $path, $options['only'])) !== null) {
                // don't check PATTERN_NEGATIVE since those entries are not prefixed with !
                return true;
            }
            return false;
        }
        return true;
    }

Usage Example

 /** @inheritdoc */
 public function bootstrap($app)
 {
     /* Config Translation */
     if (!isset($app->get('i18n')->translations['adminlte*'])) {
         $app->get('i18n')->translations['adminlte*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages'];
     }
     /* Config Theme */
     if (!isset($app->view->theme)) {
         $app->view->theme = new \yii\base\Theme(['pathMap' => ['@app/views/layouts' => '@cjtterabytesoft/adminlte/basic/views/layouts', '@app/views/site' => '@cjtterabytesoft/adminlte/basic/views/site']]);
     }
     /* Copy Avatar Images */
     if (\yii\helpers\BaseFileHelper::filterPath(\Yii::getAlias('@app/web/images'), $options = [])) {
         \yii\helpers\BaseFileHelper::copyDirectory(\Yii::getAlias('@cjtterabytesoft/adminlte/basic/images/'), \Yii::getAlias('@app/web/images'));
     }
     /* Config Params */
     if (!isset($app->params['adminEmail'])) {
         $app->params['adminEmail'] = '*****@*****.**';
     }
     if (!isset($app->params['AdminLTESkin'])) {
         $app->params['AdminLTESkin'] = 'skin-yellow';
     }
     if (!isset($app->params['Author'])) {
         $app->params['Author'] = '2015 - Wilmer Arambula';
     }
     if (!isset($app->params['Facebook_Account'])) {
         $app->params['Facebook_Account'] = 'https://www.facebook.com/username';
     }
     if (!isset($app->params['Google_Account'])) {
         $app->params['Google_Account'] = 'https://www.google.com/+username';
     }
     if (!isset($app->params['Linkedin_Account'])) {
         $app->params['Linkedin_Account'] = 'https://www.linkedin.com/in/username';
     }
     if (!isset($app->params['Twitter_Account'])) {
         $app->params['Twitter_Account'] = 'https://twitter.com/username';
     }
     if (!isset($app->params['WebName'])) {
         $app->params['WebName'] = 'My Application';
     }
     if (!YII_ENV_TEST) {
         if (!isset($app->params['imagesurl_30'])) {
             $app->params['imagesurl_30'] = 'http://www.basic.tk/images/avatar/profile/30/icon-avatar.png';
         }
         if (!isset($app->params['imagesurl_60'])) {
             $app->params['imagesurl_60'] = 'http://www.basic.tk/images/avatar/profile/60/icon-avatar.png';
         }
     } else {
         if (!isset($app->params['imagesurl_30'])) {
             $app->params['imagesurl_30'] = 'http://localhost.basic/images/avatar/profile/30/icon-avatar.png';
         }
         if (!isset($app->params['imagesurl_60'])) {
             $app->params['imagesurl_60'] = 'http://localhost.basic/images/avatar/profile/60/icon-avatar.png';
         }
     }
 }
All Usage Examples Of yii\helpers\BaseFileHelper::filterPath