loadDefaultHandlers

@return  void
350667
protected function loadDefaultHandlers()
    {
        $filter = $this->htmlCleaner;

        // INT / INTEGER
        $this->handlers[static::INTEGER] = $this->handlers['INT'] = function ($source) {
            // Only use the first integer value
            preg_match('/-?[0-9]+/', (string) $source, $matches);

            return isset($matches[0]) ? (int) $matches[0] : null;
        };

        // UINT
        $this->handlers[static::UINT] = function ($source) {
            // Only use the first integer value
            preg_match('/-?[0-9]+/', (string) $source, $matches);

            return isset($matches[0]) ? abs((int) $matches[0]) : null;
        };

        // FLOAT / DOUBLE
        $this->handlers[static::FLOAT] = $this->handlers['DOUBLE'] = function ($source) {
            // Only use the first floating point value
            preg_match('/-?[0-9]+(\.[0-9]+)?/', (string) $source, $matches);

            return isset($matches[0]) ? (float) $matches[0] : null;
        };

        // BOOLEAN / BOOL
        $this->handlers[static::BOOLEAN] = $this->handlers['BOOL'] = function ($source) {
            return (bool) $source;
        };

        // WORD
        $this->handlers[static::WORD] = function ($source) {
            return (string) preg_replace('/[^A-Z_]/i', '', $source);
        };

        // ALNUM
        $this->handlers[static::ALNUM] = function ($source) {
            return (string) preg_replace('/[^A-Z0-9]/i', '', $source);
        };

        // CMD
        $this->handlers[static::CMD] = function ($source) {
            $result = (string) preg_replace('/[^A-Z0-9_\.-]/i', '', $source);

            return ltrim($result, '.');
        };

        // BASE64
        $this->handlers[static::BASE64] = function ($source) {
            return (string) preg_replace('/[^A-Z0-9\/+=]/i', '', $source);
        };

        // STRING
        $this->handlers[static::STRING] = function ($source) use ($filter) {
            return (string) $filter->remove($filter->decode((string) $source));
        };

        // HTML
        $this->handlers[static::HTML] = function ($source) use ($filter) {
            return (string) $filter->remove((string) $source);
        };

        // ARRAY
        $this->handlers[static::ARRAY_TYPE] = function ($source) {
            return (array) $source;
        };

        // PATH
        $this->handlers[static::PATH] = function ($source) {
            $pattern = '/^[A-Za-z0-9_-]+[A-Za-z0-9_\.-]*([\\\\\/][A-Za-z0-9_-]+[A-Za-z0-9_\.-]*)*$/';
            preg_match($pattern, (string) $source, $matches);

            return isset($matches[0]) ? (string) $matches[0] : null;
        };

        // USERNAME
        $this->handlers[static::USERNAME] = function ($source) {
            return (string) preg_replace('/[\x00-\x1F\x7F<>"\'%&]/', '', $source);
        };

        // EMAIL
        $this->handlers[static::EMAIL] = function ($source) {
            return (string) filter_var($source, FILTER_SANITIZE_EMAIL);
        };

        // HTML
        $this->handlers[static::URL] = function ($source) {
            return (string) filter_var(
                $source,
                FILTER_SANITIZE_URL,
                FILTER_FLAG_QUERY_REQUIRED | FILTER_FLAG_PATH_REQUIRED
            );
        };

        // RAW
        $this->handlers[static::RAW] = function ($source) {
            return $source;
        };

        // UNKNOWN
        $this->defaultHandler = function ($source) use ($filter) {
            // Are we dealing with an array?
            if (is_array($source)) {
                foreach ($source as $key => $value) {
                    // Filter element for XSS and other 'bad' code etc.
                    if (is_string($value)) {
                        $source[$key] = $filter->remove($filter->decode($value));
                    }
                }

                return $source;
            } else {
                // Or a string?
                if (is_string($source) && !empty($source)) {
                    // Filter source for XSS and other 'bad' code etc.
                    return $filter->remove($filter->decode($source));
                } else {
                    // Not an array or string.. return the passed parameter
                    return $source;
                }
            }
        };
    }
1299195
public function buildDefaults()
    {
        $dataClasses = ClassInfo::subclassesFor(DataObject::class);
        array_shift($dataClasses);

        if (!Director::is_cli()) {
            echo "<ul>";
        }

        foreach ($dataClasses as $dataClass) {
            singleton($dataClass)->requireDefaultRecords();
            if (Director::is_cli()) {
                echo "Defaults loaded for $dataClass\n";
            } else {
                echo "<li>Defaults loaded for $dataClass</li>\n";
            }
        }

        if (!Director::is_cli()) {
            echo "</ul>";
        }
    }
803760
public static function getDefaultLoaders(): FluentDOM\Loaders {
    if (!(self::$_defaultLoaders instanceof FluentDOM\Loaders)) {
      self::$_defaultLoaders = new FluentDOM\Loaders(new FluentDOM\Loader\Standard());
    }
    return self::$_defaultLoaders;
  }
930680
public function getDeafultHandlers()
	{
		return [

			// return hash of input file

			'contenthash' => function ($file) {

				if ( ! isset($this->hasher))
				{
					$this->hasher = new Hasher;
				}

				return $this->hasher->file($file);
			},

			// return ext of input file

			'ext' => function ($file) {

				return $file->getClientOriginalExtension();
			}

		];
	}
1287409
protected function loadFunctions() : void
    {
        $this->extendForTranslator();
        $this->extendForWidget();
        $this->extendForSiteUrl();
        $this->extendForGetUrl();
        $this->extendForQueryParams();
        $this->extendForPagination();
        $this->extendForVarDump();
    }
635161
public static function getDefaultHandler()
    {
        $default = $future = null;

        if (extension_loaded('curl')) {
            $config = [
                'select_timeout' => getenv('GUZZLE_CURL_SELECT_TIMEOUT') ?: 1
            ];
            if ($maxHandles = getenv('GUZZLE_CURL_MAX_HANDLES')) {
                $config['max_handles'] = $maxHandles;
            }
            if (function_exists('curl_reset')) {
                $default = new CurlHandler();
                $future = new CurlMultiHandler($config);
            } else {
                $default = new CurlMultiHandler($config);
            }
        }

        if (ini_get('allow_url_fopen')) {
            $default = !$default
                ? new StreamHandler()
                : Middleware::wrapStreaming($default, new StreamHandler());
        } elseif (!$default) {
            throw new \RuntimeException('Guzzle requires cURL, the '
                . 'allow_url_fopen ini setting, or a custom HTTP handler.');
        }

        return $future ? Middleware::wrapFuture($default, $future) : $default;
    }
471696
private function setDefaultConfiguration(): void
    {
        $this->parameterBag->set('app.devmode', false);
        $this->parameterBag->set('container.dumper.inline_class_loader', true);

        $this->config->addPass($this->parameterBag);
    }
621459
protected function getDefaultCommands()
  {
    // Keep the core default commands to have the HelpCommand which is used when using the --help option
    $defaultCommands = parent::getDefaultCommands();

    $defaultCommands[] = new ConstantsCommand();
    $defaultCommands[] = new CrudCommand();
    $defaultCommands[] = new NonStaticCommand();
    $defaultCommands[] = new RoutineLoaderCommand();
    $defaultCommands[] = new RoutineWrapperGeneratorCommand();
    $defaultCommands[] = new StratumCommand();

    return $defaultCommands;
  }
804422
@SuppressWarnings( "deprecation" )
    protected void initArtefactHandlers() {

        List<ArtefactHandler> additionalArtefactHandlers = GrailsFactoriesLoader.loadFactories(ArtefactHandler.class, getClassLoader());

        for (ArtefactHandler artefactHandler : additionalArtefactHandlers) {
            registerArtefactHandler(artefactHandler);
        }

        updateArtefactHandlers();
    }
1364608
protected static function initHandlers () {
		$className = version_compare(PHP_VERSION, '5.5', '>') ? static::class : get_called_class();
		foreach (static::$handlers as $key => $value) {
			static::$handlers[$key] = [$className, $value];
		}
		register_shutdown_function(static::$handlers['shutdownHandler']);
	}
1329954
public function loadRegistries()
    {
        $registries = $this->registryFactory->getDefaultRegistries();

        foreach ($registries as $registry) {
            $this->addRegistry($registry);
        }
    }
1336542
private function load()
    {
        $this->locales->loadFromArray($this->getConfig('locales'));
        $this->setSupportedLocales($this->getConfig('supported-locales'));
        $this->setDefaultLocale();
    }
357385
protected function attachDefaultListeners()
    {
        parent::attachDefaultListeners();
        $events = $this->getEventManager();
        
        /*
         * "Redirect" action 'new' and 'edit' to 'form' and set the 
         * route parameter 'mode' to the original action.
         * This must run before onDispatch, because we alter the action param 
         */
        $events->attach(
            MvcEvent::EVENT_DISPATCH,
            function ($event) {
                $routeMatch = $event->getRouteMatch();
                $action     = $routeMatch->getParam('action');
            
                if ('new' == $action || 'edit' == $action) {
                    $routeMatch->setParam('mode', $action);
                    $routeMatch->setParam('action', 'form');
                }
            },
            10
        );
        
        /*
         * Inject a sidebar view model in the Layout-Model, if 
         * the result in the event is not terminal.
         * This must run after "InjectViewModelListener", which runs with
         * a priority of -100.
         */
        $events->attach(
            MvcEvent::EVENT_DISPATCH,
            function ($event) {
                $model = $event->getResult();
                if (!$model instanceof ViewModel || $model->terminate()) {
                    return;
                }
            
                $routeMatch = $event->getRouteMatch();
                $action = $routeMatch->getParam('action');
                if ('form' == $action) {
                    $action = $routeMatch->getParam('mode');
                }
            
                $layout  = $event->getViewModel();
                $sidebar = new ViewModel();
                $sidebar->setVariable('action', $action);
                $sidebar->setTemplate('auth/sidebar/groups-menu');
                $layout->addChild($sidebar, 'sidebar_auth_groups-menu');
            },
            -110
        );

        $serviceLocator  = $this->serviceLocator;
        $defaultServices = $serviceLocator->get('DefaultListeners');
        $events->attach($defaultServices);
    }
987283
protected function initLoader()
    {
        $this->versionParser = new VersionParser();

        if (!$this->loader) {
            $this->loader = new ArrayLoader($this->versionParser);
        }
    }
1159103
public function loadDefaultDecorators()
    {
        if ($this->loadDefaultDecoratorsIsDisabled()) {
            return;
        }

        $decorators = $this->getDecorators();
        if (empty($decorators)) {
            $this->addDecorator('Tabs', $this->_decoratorOptions)
                ->addDecorator('Label');
        }
    }
269428
def _loadHandlers(self):
        
        return {handler.name: handler for handler in map(self.createHandler, self.config['handlers'])}
799577
protected function defaultHandler()/*# : bool */
    {
        $status = $this->result->getStatus();
        $handler = $this->result->getHandler() ?: $this->getHandler($status);

        if ($handler) {
            $param = ['result' => $this->result];
            $callable = $this->getResolver()->resolve($handler);
            if ($this->trigger(self::EVENT_BEFORE_HANDLER, $param)) {
                call_user_func($callable, $this->result);
                $this->trigger(self::EVENT_AFTER_HANDLER, $param);
            }
        }
        return false;
    }