idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
1,800
public static function addLogger ( LoggerInterface $ logger , string $ identifier = "" ) { if ( ! isset ( self :: $ _loggers [ $ identifier ] ) ) { self :: $ _loggers [ $ identifier ] = $ logger ; } }
Adds another logger . This can be used to add loggers from other vendors . If there s another logger with the same name this method has no effect .
1,801
public static function getLoggerByIdentifier ( string $ identifier = "" ) : LoggerInterface { if ( ! isset ( self :: $ _loggers [ $ identifier ] ) ) { throw LogException :: unknownLogger ( $ identifier ) ; } return self :: $ _loggers [ $ identifier ] ; }
Returns the logger with the given name .
1,802
public function compile ( File $ template , array $ template_vars = [ ] ) : string { $ template = $ template -> makeLocal ( ) ; if ( ! empty ( $ this -> preprocessors ) ) { $ processed_code = $ template -> readAll ( ) ; foreach ( $ this -> preprocessors as $ preprocessor ) { $ processed_code = $ preprocessor -> transform ( $ processed_code ) ; } $ template = $ this -> cache -> child [ $ template -> name ] ; if ( ! ( $ template instanceof LocalFile ) ) { throw new RuntimeException ( 'Template cache is not a file' ) ; } $ template -> writeAll ( $ processed_code ) ; } $ output = $ this -> compiler -> compile ( $ template , $ template_vars ) ; foreach ( $ this -> postprocessors as $ postprocessor ) { $ output = $ postprocessor -> transform ( $ output ) ; } return $ output ; }
Executes pre - processors compiler and post - processors on a template
1,803
public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( SkillReferenceTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ gossi \ trixionary \ model \ SkillReference ) { $ criteria = $ values -> buildPkeyCriteria ( ) ; } else { $ criteria = new Criteria ( SkillReferenceTableMap :: DATABASE_NAME ) ; if ( count ( $ values ) == count ( $ values , COUNT_RECURSIVE ) ) { $ values = array ( $ values ) ; } foreach ( $ values as $ value ) { $ criterion = $ criteria -> getNewCriterion ( SkillReferenceTableMap :: COL_SKILL_ID , $ value [ 0 ] ) ; $ criterion -> addAnd ( $ criteria -> getNewCriterion ( SkillReferenceTableMap :: COL_REFERENCE_ID , $ value [ 1 ] ) ) ; $ criteria -> addOr ( $ criterion ) ; } } $ query = SkillReferenceQuery :: create ( ) -> mergeWith ( $ criteria ) ; if ( $ values instanceof Criteria ) { SkillReferenceTableMap :: clearInstancePool ( ) ; } elseif ( ! is_object ( $ values ) ) { foreach ( ( array ) $ values as $ singleval ) { SkillReferenceTableMap :: removeInstanceFromPool ( $ singleval ) ; } } return $ query -> delete ( $ con ) ; }
Performs a DELETE on the database given a SkillReference or Criteria object OR a primary key value .
1,804
public static function doInsert ( $ criteria , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( SkillReferenceTableMap :: DATABASE_NAME ) ; } if ( $ criteria instanceof Criteria ) { $ criteria = clone $ criteria ; } else { $ criteria = $ criteria -> buildCriteria ( ) ; } $ query = SkillReferenceQuery :: create ( ) -> mergeWith ( $ criteria ) ; return $ con -> transaction ( function ( ) use ( $ con , $ query ) { return $ query -> doInsert ( $ con ) ; } ) ; }
Performs an INSERT on the database given a SkillReference or Criteria object .
1,805
protected function setupCommands ( ServiceContainer $ container ) { BaseApplication :: setupCommands ( $ container ) ; $ container -> setShared ( 'console.commands.run' , function ( $ c ) { return new RunCommand ( ) ; } ) ; }
Override setup commands
1,806
public function getHtmlId ( ) { $ group = $ this -> getParentOfType ( '\\Zepi\\Web\\UserInterface\\Form\\Group' ) ; $ form = $ this -> getParentOfType ( '\\Zepi\\Web\\UserInterface\\Form' ) ; $ id = '' ; if ( $ group !== false ) { $ id = $ group -> getHtmlId ( ) . '-' ; } else if ( $ form !== false ) { $ id = $ form -> getHtmlId ( ) . '-' ; } return $ id . $ this -> key ; }
Returns the html id of this field
1,807
public function getHtmlName ( ) { $ group = $ this -> getParentOfType ( '\\Zepi\\Web\\UserInterface\\Form\\Group' ) ; $ name = '' ; if ( $ group !== false ) { $ name = $ group -> getKey ( ) . '-' ; } return $ name . $ this -> key ; }
Returns the html name of this field
1,808
public static function fromPath ( string $ path , ? Throwable $ previous = null ) : FileNotFoundException { $ message = sprintf ( 'File not found: %s' , $ path ) ; return new static ( $ message , $ path , $ previous ) ; }
Creates exception for a given path
1,809
public function all ( ) { $ thisClass = $ this -> class ; $ query = '' ; if ( isset ( $ this -> sort [ 'field' ] ) ) { $ query = $ thisClass :: orderBy ( $ this -> sort [ 'field' ] , isset ( $ this -> sort [ 'order' ] ) && $ this -> sort [ 'order' ] == 'desc' ? 'desc' : 'asc' ) ; } if ( $ this -> paginate ) { $ rows = $ query ? $ query -> paginate ( $ this -> paginate ) : $ thisClass :: paginate ( $ this -> paginate ) ; } else { $ rows = $ query ? $ query -> get ( ) : $ thisClass :: get ( ) ; } return $ rows ; }
Get all items for an entity paginated or not .
1,810
public static function entityList ( ) { $ files = File :: files ( config_path ( 'panel' ) ) ; $ list = [ ] ; foreach ( $ files as $ file ) { $ list [ ] = new self ( $ file ) ; } return collect ( $ list ) -> sortBy ( function ( $ entity ) { return $ entity -> name ( ) ; } ) ; }
Return the list of blueprints as entities .
1,811
public function name ( $ plural = false ) { if ( Lang :: has ( 'panel::entities.' . $ this -> name ) ) { return trans_choice ( 'panel::entities.' . $ this -> name , $ plural ? 2 : 1 ) ; } else { return $ plural ? str_plural ( ucwords ( $ this -> name ) ) : ucwords ( $ this -> name ) ; } }
Get the name attributed translate and properly pluralized if needed .
1,812
public static function fromYamlFile ( $ entity ) { $ path = config_path ( 'panel/' . strtolower ( str_singular ( $ entity ) ) . '.yml' ) ; if ( file_exists ( $ path ) ) { $ entity = new self ( $ path ) ; return $ entity ; } else { return false ; } }
Get Entity object from Yaml file .
1,813
static function from ( $ path , $ flags = 4096 ) { try { return new static ( new FilesystemIterator ( $ path , $ flags ) ) ; } catch ( \ Exception $ e ) { throw new \ InvalidArgumentException ( $ e -> getMessage ( ) ) ; } }
Creates a filesystem directory query .
1,814
static function recursiveFrom ( $ path , $ flags = 4096 , $ mode = self :: DIRECTORIES_FIRST ) { try { return ( new static ( new FilesystemIterator ( $ path , $ flags ) ) ) -> recursive ( function ( $ v , $ k , $ d ) use ( $ flags ) { $ p = is_string ( $ v ) ? $ v : ( $ v instanceof SplFileInfo ? $ v -> getPathname ( ) : $ k ) ; $ r = is_dir ( $ p ) ? new FilesystemIterator ( $ p , $ flags ) : null ; return $ r ; } , $ mode ) ; } catch ( \ Exception $ e ) { throw new \ InvalidArgumentException ( $ e -> getMessage ( ) ) ; } }
Creates a recursive filesystem directory query .
1,815
function onlyDirectories ( ) { return $ this -> where ( function ( $ f ) { if ( ! is_object ( $ f ) || ! $ f instanceof SplFileInfo ) throw new \ RuntimeException ( "You must use FilesystemIterator::CURRENT_AS_PATHNAME with onlyDirectories() " ) ; return $ f -> isDir ( ) ; } ) ; }
Restricts the iteration to directories only .
1,816
function onlyFiles ( ) { return $ this -> where ( function ( $ f ) { if ( ! is_object ( $ f ) || ! $ f instanceof SplFileInfo ) throw new \ RuntimeException ( "You must use FilesystemIterator::CURRENT_AS_PATHNAME with onlyFiles()" ) ; return $ f -> isFile ( ) ; } ) ; }
Restricts the iteration to files only .
1,817
public function clear ( ) { $ this -> scheme = null ; $ this -> host = null ; $ this -> user = null ; $ this -> password = null ; $ this -> path = null ; $ this -> query = null ; $ this -> fragment = null ; $ this -> port = null ; }
Resets the content of the MUrl . After calling this function the MUrl is equal to one that has been constructed with the default empty constructor .
1,818
public function setUrl ( $ url ) { if ( $ url == null ) { return null ; } $ urlParts = parse_url ( $ url ) ; $ this -> scheme = $ urlParts [ 'scheme' ] ; $ this -> host = $ urlParts [ 'host' ] ; $ this -> user = $ urlParts [ 'user' ] ; $ this -> password = $ urlParts [ 'pass' ] ; $ this -> path = $ urlParts [ 'path' ] ; $ this -> query = $ urlParts [ 'query' ] ; $ this -> fragment = $ urlParts [ 'fragment' ] ; $ this -> port = $ urlParts [ 'port' ] ; return $ this ; }
Parses url and sets this object to that value .
1,819
public function setUserInfo ( $ userInfo ) { $ userInfoParts = explode ( ":" , $ userInfo ) ; $ this -> user = $ userInfoParts [ 0 ] ; $ this -> password = $ userInfoParts [ 1 ] ; return $ this ; }
Sets the user info of the URL to userInfo .
1,820
public function getUrl ( ) { $ scheme = $ this -> scheme != null ? $ this -> scheme . '://' : MString :: EMPTY_STRING ; $ host = $ this -> host != null ? $ this -> host : MString :: EMPTY_STRING ; $ port = $ this -> port != null ? ':' . $ this -> port : MString :: EMPTY_STRING ; $ user = $ this -> user != null ? $ this -> user : MString :: EMPTY_STRING ; $ pass = $ this -> password != null ? ':' . $ this -> password : MString :: EMPTY_STRING ; $ pass = ( $ user || $ pass ) ? "$pass@" : MString :: EMPTY_STRING ; $ path = $ this -> path != null ? $ this -> path : MString :: EMPTY_STRING ; $ query = $ this -> query != null ? '?' . $ this -> query : MString :: EMPTY_STRING ; $ fragment = $ this -> fragment != null ? '#' . $ this -> fragment : MString :: EMPTY_STRING ; return $ scheme . $ user . $ pass . $ host . $ port . $ path . $ query . $ fragment ; }
Returns a string representation of the URL .
1,821
public function getUserInfo ( ) { return ( MString :: isNullOrEmpty ( $ this -> user ) ? MString :: EMPTY_STRING : $ this -> user ) . ( MString :: isNullOrEmpty ( $ this -> password ) ? MString :: EMPTY_STRING : ':' . $ this -> password ) ; }
Returns the user info of the URL or an empty string if the user info is undefined .
1,822
public function loginByUser ( Model $ pUser ) { $ this -> logout ( ) ; $ this -> _user = $ pUser ; if ( $ this -> _user -> getId ( ) ) { $ this -> _session -> userId = $ this -> _user -> getId ( ) ; return true ; } return false ; }
Log in the user with a given User model .
1,823
public function login ( array $ pFields ) { $ this -> logout ( ) ; $ conditions = new Conditions ( ) ; foreach ( $ pFields as $ field => $ value ) { $ conditions -> add ( $ field , Conditions :: EQ , $ value ) ; } $ this -> _user -> load ( array ( DbInterface :: FILTER_CONDITIONS => $ conditions ) ) ; if ( $ this -> _user -> getId ( ) ) { $ this -> _session -> userId = $ this -> _user -> getId ( ) ; return true ; } return false ; }
Log in the user based on specified fields .
1,824
public function logout ( ) { $ this -> _user = Agl :: getModel ( self :: USER_DB_CONTAINER ) ; unset ( $ this -> _session -> userId ) ; return $ this ; }
Log out the user an destroy it from the session .
1,825
public function getRole ( ) { if ( $ this -> _user === NULL ) { $ this -> _initUser ( ) ; } if ( $ this -> _user -> getRole ( ) ) { return $ this -> _user -> getRole ( ) ; } return Acl :: DEFAULT_ROLE ; }
Return the role of the current user .
1,826
protected function createEntityListBuilder ( array $ entities , $ listTypeClass = null , array $ options = array ( ) ) { return $ this -> get ( 'jgp_entity_list.list_factory' ) -> createListBuilder ( $ entities , $ listTypeClass , $ options ) ; }
Factory method to create a list builder
1,827
protected function createEntityList ( array $ entities , $ listTypeClass = ListType :: class , array $ options = array ( ) ) { return $ this -> get ( 'jgp_entity_list.list_factory' ) -> createList ( $ entities , $ listTypeClass , $ options ) ; }
Factory method to create a list from an existent list type
1,828
protected function wrap ( callable $ process , $ successSpecResult = null ) : ResponseInterface { try { $ result = $ process ( ) ; } catch ( ValidationException $ e ) { return $ this -> failWithException ( $ e ) ; } catch ( UserAuthException $ e ) { return $ this -> failWithAuth ( ) ; } catch ( NotFoundHttpException $ e ) { return $ this -> failWithNotFound ( ) ; } catch ( \ Throwable $ e ) { return $ this -> failWithException ( $ e ) ; } if ( ! is_null ( $ successSpecResult ) ) { $ result = $ successSpecResult ; } if ( $ result instanceof ResponseInterface ) { return $ result ; } return $ this -> success ( $ result ) ; }
E . g . wrapping regular controller action into try ... catch block take the process as callback
1,829
public function getHtml ( ) : string { $ head = ( new HeadGenerator ( $ this ) ) -> render ( ) ; $ body = ( new BodyGenerator ( $ this ) ) -> render ( ) ; return "<!doctype html><html>$head$body</html>" ; }
Function for return html from generators .
1,830
protected function getPackagePath ( ) { $ reflection = new ReflectionObject ( $ this ) ; $ fileName = $ reflection -> getFileName ( ) ; $ packagePath = dirname ( dirname ( dirname ( dirname ( dirname ( dirname ( $ fileName ) ) ) ) ) ) ; return $ packagePath ; }
Overload if child class is in non - standard directory
1,831
public function formatted ( ) { $ doc = dom_import_simplexml ( $ this -> root ) -> ownerDocument ; $ doc -> preserveWhiteSpace = false ; $ doc -> formatOutput = true ; $ doc -> encoding = 'UTF-8' ; return $ doc -> saveXML ( ) ; }
Get the formatted XML string .
1,832
public function set ( $ path , $ value ) { $ entries = explode ( '/' , $ path ) ; $ lastEntry = array_pop ( $ entries ) ; reset ( $ entries ) ; $ xml = $ this -> root ; foreach ( $ entries as $ pathEntry ) { $ xml = $ this -> getOrCreateNextElement ( $ xml , $ pathEntry ) ; } list ( $ elementName , $ elementIndex ) = $ this -> parsePathEntry ( $ lastEntry ) ; if ( $ elementIndex === '' ) { $ xml -> addChild ( $ elementName , $ value ) ; return $ this ; } if ( $ elementIndex === null ) { $ xml -> $ elementName = $ value ; return $ this ; } if ( $ elementName === '' ) { $ xml [ $ elementIndex ] = $ value ; return $ this ; } if ( is_string ( $ elementIndex ) && empty ( $ xml -> $ elementName ) ) { $ el = $ xml -> addChild ( $ elementName ) ; } else { $ el = $ xml -> $ elementName ; } $ el [ $ elementIndex ] = $ value ; return $ this ; }
Set a value on the xml doc .
1,833
public function struct ( $ ignoreWhitespace , $ ignoreCase ) { $ parser = xml_parser_create ( ) ; xml_parser_set_option ( $ parser , XML_OPTION_SKIP_WHITE , $ ignoreWhitespace ? 1 : 0 ) ; xml_parser_set_option ( $ parser , XML_OPTION_CASE_FOLDING , $ ignoreCase ? 1 : 0 ) ; xml_parse_into_struct ( $ parser , $ this -> root ( ) -> asXml ( ) , $ struct , $ index ) ; xml_parser_free ( $ parser ) ; return $ struct ; }
Get array struct from XML .
1,834
public function sameAs ( $ other , $ ignoreWhitespace , $ ignoreCase ) { if ( is_string ( $ other ) ) { $ prev = libxml_use_internal_errors ( true ) ; $ otherSimpleXml = @ simplexml_load_string ( $ other ) ; libxml_use_internal_errors ( $ prev ) ; if ( ! ( $ otherSimpleXml instanceof SimpleXmlElement ) ) { throw new LogicException ( 'Argument 0 was an invalid XML string' ) ; } $ otherXml = new static ( $ otherSimpleXml ) ; } elseif ( $ other instanceof SimpleXmlElement ) { $ otherXml = new static ( $ other ) ; } elseif ( $ other instanceof self ) { $ otherXml = $ other ; } else { throw new LogicException ( sprintf ( 'Argument 0 must be a string, a SimpleXmlElement or an instance of %s. %s given' , __CLASS__ , gettype ( $ xml ) ) ) ; } return $ otherXml -> struct ( $ ignoreWhitespace , $ ignoreCase ) == $ this -> struct ( $ ignoreWhitespace , $ ignoreCase ) ; }
Check if XML is the same as another within certain criteria .
1,835
public static function createGlobal ( ) { $ uri = new Uri ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) ? $ _SERVER [ 'REQUEST_URI' ] : '' ) ; $ method = isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) ? $ _SERVER [ 'REQUEST_METHOD' ] : 'GET' ; $ request = new self ( $ uri , $ method , $ _GET , $ _POST , $ _COOKIE , UploadedFile :: convert ( $ _FILES ) , $ _SERVER ) ; foreach ( $ _SERVER as $ name => $ value ) { if ( substr_compare ( $ name , 'HTTP_' , 0 , 5 ) === 0 ) { $ request -> setHeader ( str_replace ( '_' , '-' , substr ( $ name , 5 ) ) , $ value ) ; } } return $ request ; }
Create a request from PHP s superglobals .
1,836
public function wrap ( $ template ) { $ this -> template = Template \ Loader :: load ( $ template ) ; $ groundTemplate = Template \ Loader :: load ( 'templates.layout.ground' ) ; return $ groundTemplate ; }
Wraps initial template with ground layout
1,837
public static function Rxr ( array $ a , array $ b , array & $ atb ) { $ i ; $ j ; $ k ; $ w ; $ wm = [ ] ; for ( $ i = 0 ; $ i < 3 ; $ i ++ ) { for ( $ j = 0 ; $ j < 3 ; $ j ++ ) { $ w = 0.0 ; for ( $ k = 0 ; $ k < 3 ; $ k ++ ) { $ w += $ a [ $ i ] [ $ k ] * $ b [ $ k ] [ $ j ] ; } $ wm [ $ i ] [ $ j ] = $ w ; } } IAU :: Cr ( $ wm , $ atb ) ; return ; }
- - - - - - - i a u R x r - - - - - - -
1,838
public function resolve ( InputInterface $ input , GeneratorInterface $ generator , $ forceInteractive = false ) { $ definition = $ generator -> getDefinition ( ) ; $ definition = $ this -> mergeApplicationDefinition ( $ definition ) ; $ definition = new InputDefinition ( $ definition ) ; $ input = clone $ input ; try { $ input -> bind ( $ definition ) ; $ input -> validate ( ) ; } catch ( \ Exception $ ex ) { $ forceInteractive = true ; } $ arguments = array_merge ( $ input -> getArguments ( ) , $ input -> getOptions ( ) ) ; $ arguments = new Arguments ( $ arguments , $ forceInteractive || $ generator -> requiresInteraction ( ) ) ; return $ arguments ; if ( $ forceInteractive || $ generator -> requiresInteraction ( ) ) { if ( ! $ input -> isInteractive ( ) ) { throw new \ RuntimeException ( "Cannot interact with user." ) ; } $ constraints = $ generator -> getConstraints ( ) ; $ questioner = new Questioner ( $ inputTypeRegistry , $ this -> output , $ this -> helperSet , $ constraints ) ; $ arguments = $ generator -> interact ( $ arguments , $ questioner ) ; } return $ arguments ; }
Grab the input arguments for the given generator from the input or ask interactively .
1,839
private function getBoundingBox ( ImageInterface $ image ) { $ box = $ image -> getSize ( ) -> widen ( $ this -> size -> getWidth ( ) ) ; if ( $ box -> getHeight ( ) >= $ this -> size -> getHeight ( ) ) { return $ box ; } return $ image -> getSize ( ) -> heighten ( $ this -> size -> getHeight ( ) ) ; }
Get bounding box
1,840
private function getStartPoint ( BoxInterface $ boundingBox ) { $ x = ( int ) round ( 0.5 * ( $ boundingBox -> getWidth ( ) - $ this -> size -> getWidth ( ) ) ) ; $ y = ( int ) round ( 0.5 * ( $ boundingBox -> getHeight ( ) - $ this -> size -> getHeight ( ) ) ) ; return new Point ( $ x , $ y ) ; }
Get starting point that size box is centered
1,841
public function send ( ) { foreach ( $ this -> headers as $ header ) { header ( $ header -> getString ( ) , $ header -> getReplace ( ) , $ header -> getHttpResponseCode ( ) ) ; } }
Sends all headers of stack
1,842
public function location ( string $ location , bool $ permanent = false ) { $ header = new Location ( $ location ) ; if ( $ permanent ) { $ header -> setPermanent ( $ permanent ) ; } $ this -> addHeader ( $ header ) ; }
Creates a location header
1,843
public function contentType ( string $ content_type , string $ charset = '' ) { $ header = new ContentType ( $ content_type ) ; if ( ! empty ( $ charset ) ) { $ header -> setCharset ( $ charset ) ; } $ this -> addHeader ( $ header ) ; }
Content type header
1,844
public function noCache ( ) { $ header = new Expires ( 'Mon, 26 Jul 1997 05:00:00 GMT' ) ; $ this -> addHeader ( $ header ) ; $ header = new CacheControl ( 'no-cache' ) ; $ this -> addHeader ( $ header ) ; $ header = new Pragma ( 'no-cache' ) ; $ this -> addHeader ( $ header ) ; }
Create no caching headers
1,845
public function isSubdomainUriExists ( $ subdomainId , $ uri , $ excludeUriId = null ) { return $ this -> isExists ( empty ( $ excludeUriId ) ? array ( 'subdomainId' => $ subdomainId , 'uri' => $ uri , ) : array ( 'subdomainId' => $ subdomainId , 'uri' => $ uri , new Predicate \ Operator ( 'id' , Predicate \ Operator :: OP_NE , $ excludeUriId ) , ) ) ; }
Return true if uri is exists in a subdomain
1,846
public function findFailedLAGPorts ( ) { $ lagPorts = $ this -> isAggregatePorts ( ) ; $ attachedPorts = $ this -> portAttachedIds ( ) ; foreach ( $ lagPorts as $ portId => $ isLAG ) { if ( ! $ isLAG ) { unset ( $ lagPorts [ $ portId ] ) ; continue ; } if ( $ attachedPorts [ $ portId ] != 0 ) unset ( $ lagPorts [ $ portId ] ) ; } return ( $ lagPorts ) ; }
Utility function to identify configured but unattached LAG ports
1,847
public function randomColor ( ) { mt_srand ( ( double ) microtime ( ) * 1000000 ) ; $ c = '' ; while ( strlen ( $ c ) < 6 ) { $ c .= sprintf ( "%02X" , mt_rand ( 0 , 255 ) ) ; } return '#' . $ c ; }
Generate Random Color
1,848
public function generateRandomString ( $ length = 32 , $ specialCharacters = true ) { $ digits = '' ; $ chars = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789" ; if ( $ specialCharacters === true ) { $ chars .= "!?=/&+,." ; } for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ x = mt_rand ( 0 , strlen ( $ chars ) - 1 ) ; $ digits .= $ chars { $ x } ; } return $ digits ; }
Generate Random String Exclude 0 and O
1,849
public function register ( ) { $ this -> registerEvents ( ) ; $ this -> registerFiles ( ) ; $ this -> registerConfigs ( ) ; $ this -> registerEncrypter ( ) ; $ this -> registerDiscover ( ) ; }
Register objetos base .
1,850
protected function registerDiscover ( ) { $ this -> app -> singleton ( 'manifest' , function ( ) { return new PackageManifest ( $ this -> app [ 'files' ] , $ this -> app -> basePath ( ) , $ this -> app -> basePath ( 'app/packages.php' ) ) ; } ) ; $ this -> app -> alias ( 'manifest' , 'Nano7\Foundation\Discover\PackageManifest' ) ; $ this -> command ( '\Nano7\Foundation\Discover\Console\PackageDiscoverCommand' ) ; }
Register discover .
1,851
protected function registerEncrypter ( ) { $ this -> app -> singleton ( 'encrypter' , function ( $ app ) { $ key = $ app [ 'config' ] -> get ( 'app.key' ) ; $ cipher = $ app [ 'config' ] -> get ( 'app.cipher' ) ; if ( empty ( $ key ) ) { throw new \ RuntimeException ( 'No application encryption key has been specified.' ) ; } if ( Str :: startsWith ( $ key , 'base64:' ) ) { $ key = base64_decode ( substr ( $ key , 7 ) ) ; } return new Encrypter ( $ key , $ cipher ) ; } ) ; $ this -> app -> singleton ( 'bcrypt' , function ( $ app ) { return new BcryptHasher ( $ app [ 'config' ] -> get ( 'encrypter' , [ ] ) ) ; } ) ; }
Register encrypter .
1,852
protected function registerException ( ) { $ this -> app -> singleton ( 'Nano7\Foundation\Contracts\Exception\ExceptionHandler' , function ( $ app ) { $ except = new \ Nano7 \ Foundation \ Exception \ ExceptionHandler ( ) ; if ( $ app -> resolved ( 'view' ) ) { $ except -> setViewService ( $ app [ 'view' ] ) ; } return $ except ; } ) ; }
Register control exception .
1,853
public function isNumeric ( ) { $ IsNumeric = false ; if ( $ this -> type == "integer" || $ this -> type == "bigint" ) { $ IsNumeric = true ; } return $ IsNumeric ; }
Return true if property is numeric a type .
1,854
public function viewAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ file = $ em -> find ( 'Orkestra\Bundle\ApplicationBundle\Entity\File' , $ id ) ; if ( ! $ file || ! file_exists ( $ file -> getPath ( ) ) ) { throw $ this -> createNotFoundException ( 'Unable to locate File' ) ; } $ securityContext = $ this -> get ( 'security.context' ) ; foreach ( $ file -> getGroups ( ) as $ group ) { if ( ! $ securityContext -> isGranted ( $ group -> getRole ( ) ) ) { throw $ this -> createNotFoundException ( 'Unable to locate File' ) ; } } $ response = new Response ( ) ; $ response -> setLastModified ( new \ DateTime ( '@' . filemtime ( $ file -> getPath ( ) ) ) ) ; $ response -> setPublic ( ) ; if ( ( $ hash = $ file -> getMd5 ( ) ) !== '' ) { $ response -> setEtag ( $ hash ) ; } if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ response -> setContent ( $ file -> getContent ( ) ) ; $ response -> headers -> add ( array ( 'Content-Type' => $ file -> getMimeType ( ) , ) ) ; return $ response ; }
Outputs a file
1,855
public static function toKeysArray ( ResultIterator $ iterator ) { $ keys = array ( ) ; foreach ( $ iterator as $ result ) { $ keys [ ] = $ result -> getKey ( ) ; } return $ keys ; }
Returns an array with the keys
1,856
protected function findRelatedIssues ( RepositoryInterface $ repository , $ message ) { $ issues = [ ] ; foreach ( $ this -> findShortnamesInMessage ( $ message ) as $ shortName ) { $ shortNameAndNumber = explode ( '-' , $ shortName ) ; $ issues = array_merge ( $ this -> issueRepository -> findRelatedIssuesByRepository ( $ repository , $ shortNameAndNumber [ 0 ] , $ shortNameAndNumber [ 1 ] ) , $ issues ) ; } return $ issues ; }
Finds related issues for repository and message given .
1,857
public function push ( ) { if ( isset ( $ this -> broadcast ) && ! is_null ( $ this -> broadcast ) ) { $ this -> connect ( ) ; $ this -> socket -> send ( json_encode ( $ this -> broadcast ) ) ; } }
Push a message to a subscription socket .
1,858
protected function connect ( ) { $ this -> context = new ZMQContext ( $ this -> ioThreadTotal , $ this -> persistent ) ; $ this -> socket = $ this -> context -> getSocket ( $ this -> socketType , $ this -> persistenceKey ) ; $ this -> socket -> connect ( $ this -> connection ) ; }
Connect to the subscription socket .
1,859
public function setCategories ( $ post ) { foreach ( $ post -> getCategories ( ) as $ category ) { $ categoryName = strtolower ( $ category -> getName ( ) ) ; if ( in_array ( $ categoryName , array_map ( 'strtolower' , $ this -> categoriesName ) ) ) { $ this -> categories [ $ categoryName ] -> setPost ( $ post ) ; continue ; } $ this -> categories [ $ categoryName ] = new Category ( $ categoryName ) ; $ this -> categories [ $ categoryName ] -> setPost ( $ post ) ; $ this -> categoriesName [ ] = $ categoryName ; } }
Get all Site Categories
1,860
public static function getInstance ( $ name = null ) { if ( ! $ name ) { $ name = 'default' ; } if ( ! isset ( static :: $ instances [ $ name ] ) ) { static :: make ( $ name ) ; } return static :: $ instances [ $ name ] ; }
Get an unique instance of SQLAdapter by its name
1,861
public static function make ( $ name = 'default' ) { $ configs = static :: listConfig ( ) ; if ( ! isset ( $ configs [ $ name ] ) ) { throw new SQLException ( 'Database configuration with name "' . $ name . '" not found.' , 'Loading configuration' ) ; } $ config = $ configs [ $ name ] ; if ( empty ( $ config [ 'driver' ] ) ) { throw new SQLException ( 'Database configuration with name "' . $ name . '" has no driver property.' , 'Loading configuration' ) ; } if ( empty ( static :: $ adapters [ $ config [ 'driver' ] ] ) ) { throw new SQLException ( 'Database configuration with name "' . $ name . '" requires an unknown driver "' . $ config [ 'driver' ] . '".' , 'Loading configuration' ) ; } $ adapterClass = static :: $ adapters [ $ config [ 'driver' ] ] ; return new $ adapterClass ( $ name , $ config ) ; }
Try to make a SQLAdapter by its name loading from configuration
1,862
public static function listConfig ( ) { if ( static :: $ configs !== null ) { return static :: $ configs ; } $ cache = new APCache ( 'sqladapter' , 'db_configs' , 2 * 3600 ) ; if ( ! $ cache -> get ( $ configs ) ) { $ fileCconfig = IniConfig :: build ( DBCONF , true , false ) -> all ; $ configs = array ( ) ; foreach ( $ fileCconfig as $ key => $ value ) { if ( is_array ( $ value ) ) { $ configs [ $ key ] = $ value ; } else { if ( ! isset ( $ configs [ 'default' ] ) ) { $ configs [ 'default' ] = array ( ) ; } $ configs [ 'default' ] [ $ key ] = $ value ; } } $ cache -> set ( $ configs ) ; } return static :: $ configs = $ configs ; }
List all instance s configuration
1,863
public function formatValueList ( array $ list ) { $ string = '' ; foreach ( $ list as $ i => $ v ) { $ string .= ( $ i ? ',' : '' ) . $ this -> formatValue ( $ v ) ; } return $ string ; }
Format a list of values
1,864
public static function doSelect ( array $ options = array ( ) , $ instance = null , $ IDField = null ) { self :: prepareQuery ( $ options , $ instance , $ IDField ) ; return self :: $ instances [ $ instance ] -> select ( $ options ) ; }
The static function to use for SELECT queries in global context
1,865
public static function doUpdate ( array $ options = array ( ) , $ instance = null , $ IDField = null ) { self :: prepareQuery ( $ options , $ instance , $ IDField ) ; return self :: $ instances [ $ instance ] -> update ( $ options ) ; }
The static function to use for UPDATE queries in global context
1,866
public static function doDelete ( array $ options = array ( ) , $ instance = null , $ IDField = null ) { self :: prepareQuery ( $ options , $ instance , $ IDField ) ; return self :: $ instances [ $ instance ] -> delete ( $ options ) ; }
The static function to use for DELETE queries in global context
1,867
public static function doInsert ( array $ options = array ( ) , $ instance = null , $ IDField = null ) { self :: prepareQuery ( $ options , $ instance , $ IDField ) ; return self :: $ instances [ $ instance ] -> insert ( $ options ) ; }
The static function to use for INSERT queries in global context
1,868
public static function doLastID ( $ table , $ IDField = 'id' , $ instance = null ) { $ options = array ( ) ; self :: prepareQuery ( $ options , $ instance , $ IDField ) ; return self :: $ instances [ $ instance ] -> lastID ( $ table ) ; }
The static function to use to get last isnert id in global context
1,869
public static function doFormatValue ( $ value , $ instance = null ) { self :: prepareInstance ( $ instance ) ; return self :: $ instances [ $ instance ] -> formatValue ( $ value ) ; }
The static function to quote
1,870
public static function prepareQuery ( array & $ options = array ( ) , & $ instance = null , $ IDField = null ) { self :: prepareInstance ( $ instance ) ; self :: $ instances [ $ instance ] -> setIDField ( $ IDField ) ; if ( ! empty ( $ options ) && ! empty ( $ options [ 'output' ] ) && $ options [ 'output' ] == SQLAdapter :: ARR_FIRST ) { $ options [ 'number' ] = 1 ; } }
Prepare the query for the given instance
1,871
public static function prepareInstance ( & $ instance = null ) { if ( isset ( self :: $ instances [ $ instance ] ) ) { return ; } global $ DBS ; $ instance = ensure_pdoinstance ( $ instance ) ; if ( empty ( $ DBS [ $ instance ] ) ) { throw new Exception ( "Adapter unable to connect to the database." ) ; } if ( empty ( static :: $ adapters [ $ DBS [ $ instance ] [ 'driver' ] ] ) ) { throw new Exception ( "Adapter not found for driver {$DBS[$instance]['driver']}." ) ; } $ adapterClass = static :: $ adapters [ $ DBS [ $ instance ] [ 'driver' ] ] ; self :: $ instances [ $ instance ] = new $ adapterClass ( $ instance , $ DBS [ $ instance ] ) ; if ( empty ( self :: $ instances [ $ instance ] ) ) { self :: $ instances [ $ instance ] = & self :: $ instances [ $ instance ] ; } }
The static function to prepareInstance an adapter for the given instance
1,872
protected function loop ( ) { $ data = [ ] ; $ meta = [ ] ; $ this -> args = apply_filters ( Collection \ Filter :: COLLECTION_ARGS , $ this -> args ) ; $ this -> query = new \ WP_Query ( $ this -> args ) ; while ( $ this -> query -> have_posts ( ) ) { $ this -> query -> the_post ( ) ; $ data [ ] = $ this -> format_item ( $ this -> query -> post ) ; if ( empty ( $ meta ) ) { $ meta = \ Lean \ Utils \ Meta \ Collection :: get_all_collection_meta ( $ this -> query -> post ) ; } } wp_reset_postdata ( ) ; $ response = [ 'data' => $ data , 'meta' => $ meta , 'pagination' => $ this -> get_pagination ( $ this -> query -> found_posts , $ this -> query -> max_num_pages ) , ] ; return apply_filters ( Collection \ Filter :: COLLECTION_DATA , $ response , $ this -> args ) ; }
WP_Query Loop that has been triggered from the endpoint .
1,873
protected function format_item ( $ the_post ) { $ the_author = get_userdata ( $ the_post -> post_author ) ; $ item = [ 'id' => $ the_post -> ID , 'title' => $ the_post -> post_title , 'link' => get_permalink ( $ the_post -> ID ) , 'slug' => $ the_post -> post_name , 'excerpt' => get_the_excerpt ( ) , 'author' => [ 'id' => $ the_author -> ID , 'first_name' => $ the_author -> first_name , 'last_name' => $ the_author -> last_name , 'posts_link' => str_replace ( home_url ( ) , '' , get_author_posts_url ( $ the_author -> ID ) ) , ] , 'date' => strtotime ( $ the_post -> post_date_gmt ) * 1000 , 'thumbnail' => Collection \ Post :: get_thumbnail ( $ the_post , $ this -> args ) , 'terms' => Collection \ Post :: get_terms ( $ the_post ) , ] ; return apply_filters ( Collection \ Filter :: ITEM_FORMAT , $ item , $ the_post , $ this -> args ) ; }
This function allow to format every item that is returned to the endpoint the filter sends 3 params to the user so can be more easy to manipulate the data based on certain params .
1,874
public function endpoint_args ( ) { return [ 'post_type' => [ 'default' => 'post' , 'sanitize_callback' => function ( $ post_type ) { if ( is_array ( $ post_type ) ) { return array_map ( 'sanitize_text_field' , $ post_type ) ; } else { return sanitize_text_field ( $ post_type ) ; } } , ] , 'post_status' => [ 'default' => 'publish' , 'validate_callback' => function ( $ post_status ) { return 'publish' === $ post_status ; } , ] , 'has_password' => [ 'validate_callback' => '__return_false' ] , 'post_password' => [ 'validate_callback' => '__return_false' ] , ] ; }
Clean up and make sure we don t deliver post with password privates and some other datat that might be sensible on the API . This medhod overrides the default mechanism inherint from the parent class .
1,875
function scope ( $ prefix , callable $ callback ) { $ routes = new static ( $ this -> defaultRoute ) ; $ callback ( $ routes ) ; $ this -> scopes [ $ prefix ] = $ routes ; return $ this ; }
Scopes all routes in the collection to the given path
1,876
function redirect ( $ to , $ options = [ ] ) { return function ( \ Silex \ Application $ app ) use ( $ to , $ options ) { $ headers = ( array ) @ $ options [ 'headers' ] ; $ status = @ $ options [ 'status' ] ? : 302 ; $ params = ( array ) @ $ options [ 'params' ] ; $ absolute = @ $ options [ 'absolute' ] ? : false ; if ( $ route = $ app [ 'routes' ] -> get ( $ to ) ) { $ to = $ app [ 'url_generator' ] -> generate ( $ to , $ params , $ absolute ) ; } return new RedirectResponse ( $ to , $ status , $ headers ) ; } ; }
Returns a controller which redirects to the specified URL .
1,877
function resources ( $ resourceName , $ options = [ ] ) { $ controller = @ $ options [ 'controller' ] ? : $ resourceName ; $ this -> get ( "/$resourceName" , "$controller#index" ) -> bind ( "{$resourceName}_index" ) ; $ this -> get ( "/$resourceName/new" , "$controller#new" ) -> bind ( "{$resourceName}_new" ) ; $ this -> get ( "/$resourceName/{id}" , "$controller#show" ) -> bind ( "{$resourceName}_show" ) ; $ this -> get ( "/$resourceName/{id}/edit" , "$controller#edit" ) -> bind ( "{$resourceName}_edit" ) ; $ this -> post ( "/$resourceName" , "$controller#create" ) -> bind ( "{$resourceName}_create" ) ; $ this -> put ( "/$resourceName/{id}" , "$controller#update" ) -> bind ( "{$resourceName}_update" ) ; $ this -> delete ( "/$resourceName/{id}" , "$controller#destroy" ) -> bind ( "{$resourceName}_destroy" ) ; return $ this ; }
Define routes for a collection of resources .
1,878
public static function urlEncode ( $ parms ) { $ payload = array ( ) ; foreach ( $ parms as $ key => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ item ) { $ payload [ ] = urlencode ( $ key ) . '=' . urlencode ( $ item ) ; } } else { $ payload [ ] = urlencode ( $ key ) . '=' . urlencode ( $ value ) ; } } return implode ( '&' , $ payload ) ; }
Make a URL - encoded string from a key = > value array
1,879
public static function mergeCurlOptions ( $ base , $ additional ) { if ( null === $ additional || empty ( $ additional ) ) { return $ base ; } foreach ( $ additional as $ key => $ val ) { if ( ! is_int ( $ key ) ) { try { $ curlkey = constant ( $ key ) ; } catch ( Exception $ ignored ) { } if ( null === $ curlkey ) { throw new \ InvalidArgumentException ( "Invalid curl option [{$key}]." ) ; } $ key = $ curlkey ; } if ( CURLOPT_HTTPHEADER == $ key && array_key_exists ( CURLOPT_HTTPHEADER , $ base ) ) { if ( is_array ( $ val ) ) { foreach ( $ val as $ header ) { $ base [ CURLOPT_HTTPHEADER ] [ ] = $ header ; } } else { $ base [ CURLOPT_HTTPHEADER ] [ ] = $ val ; } } else { $ base [ $ key ] = $ val ; } } return $ base ; }
Merge two arrays of curl options together into a new array .
1,880
public static function ensureCurlErrorConstants ( ) { $ defs = array ( 'CURLE_COULDNT_CONNECT' => 7 , 'CURLE_COULDNT_RESOLVE_HOST' => 6 , 'CURLE_HTTP_RETURNED_ERROR' => 22 , 'CURLE_OPERATION_TIMEDOUT' => 28 , 'CURLE_PEER_FAILED_VERIFICATION' => 51 , 'CURLE_SSL_CACERT' => 60 , 'CURLE_SSL_CACERT_BADFILE' => 77 , 'CURLE_SSL_CERTPROBLEM' => 58 , 'CURLE_SSL_CIPHER' => 59 , 'CURLE_SSL_CONNECT_ERROR' => 35 , 'CURLE_SSL_CRL_BADFILE' => 82 , 'CURLE_SSL_ENGINE_INITFAILED' => 66 , 'CURLE_SSL_ENGINE_NOTFOUND' => 53 , 'CURLE_SSL_ENGINE_SETFAILED' => 54 , 'CURLE_SSL_ISSUER_ERROR' => 83 , 'CURLE_SSL_SHUTDOWN_FAILED' => 80 , 'CURLE_UNSUPPORTED_PROTOCOL' => 1 , 'CURLE_URL_MALFORMAT' => 3 , 'CURLE_USE_SSL_FAILED' => 64 , ) ; foreach ( $ defs as $ constName => $ errCode ) { if ( ! defined ( $ constName ) ) { define ( $ constName , $ errCode ) ; } } }
Ensure that constants are available for useful cURL error codes .
1,881
public static function addQueryData ( $ url , $ parms ) { if ( is_array ( $ parms ) ) { $ payload = self :: urlEncode ( $ parms ) ; } else if ( null !== $ parms ) { $ payload = ( string ) $ parms ; } if ( ! empty ( $ payload ) ) { $ parts = parse_url ( $ url ) ; if ( isset ( $ parts [ 'query' ] ) ) { $ parts [ 'query' ] .= "&{$payload}" ; } else { $ parts [ 'query' ] = $ payload ; } $ url = self :: assembleUrl ( $ parts ) ; } return $ url ; }
Append a query string to the given URL .
1,882
public static function parseCookieHeader ( $ hdr ) { $ cookies = array ( ) ; $ i = 0 ; $ from = 0 ; $ len = mb_strlen ( $ hdr , 'latin1' ) ; $ quoted = false ; while ( $ i < $ len ) { if ( '"' === $ hdr [ $ i ] && '\\' !== $ elm [ $ i - 1 ] ) { $ quoted = ! $ quoted ; } $ elm = null ; if ( ! $ quoted && ',' === $ hdr [ $ i ] ) { $ chunk = mb_substr ( $ hdr , $ from , $ i - $ from , 'latin1' ) ; $ elm = self :: parseCookieElement ( $ chunk ) ; $ from = $ i + 1 ; } else if ( $ i === $ len - 1 ) { $ chunk = mb_substr ( $ hdr , $ from , $ len - $ from , 'latin1' ) ; $ elm = self :: parseCookieElement ( $ chunk ) ; } if ( null !== $ elm && isset ( $ elm [ self :: COOKIE_NAME ] ) ) { $ cookies [ ] = $ elm ; } $ i += 1 ; } return $ cookies ; }
Parse a Set - Cookie header to get the component cookie data .
1,883
protected static function parseCookieElement ( $ elm ) { $ cookie = array ( ) ; $ i = 0 ; $ from = 0 ; $ len = mb_strlen ( $ elm , 'latin1' ) ; $ quoted = false ; while ( $ i < $ len ) { if ( '"' === $ elm [ $ i ] && '\\' !== $ elm [ $ i - 1 ] ) { $ quoted = ! $ quoted ; } $ chunk = null ; if ( ! $ quoted && ';' === $ elm [ $ i ] ) { $ chunk = mb_substr ( $ elm , $ from , $ i - $ from , 'latin1' ) ; $ from = $ i + 1 ; } else if ( $ i === $ len - 1 ) { $ chunk = mb_substr ( $ elm , $ from , $ len - $ from , 'latin1' ) ; } if ( null !== $ chunk ) { $ parts = explode ( '=' , $ chunk , 2 ) ; if ( count ( $ parts ) == 1 ) { $ name = trim ( $ parts [ 0 ] ) ; $ cookie [ $ name ] = true ; } else { $ name = trim ( $ parts [ 0 ] ) ; $ val = trim ( $ parts [ 1 ] ) ; $ val = trim ( $ val , '"' ) ; if ( empty ( $ cookie ) ) { $ cookie [ self :: COOKIE_NAME ] = $ name ; $ cookie [ self :: COOKIE_VALUE ] = $ val ; } else { $ cookie [ $ name ] = $ val ; } } } $ i += 1 ; } return $ cookie ; }
Parse a single cookie setting .
1,884
public function group_for_name ( $ name ) { foreach ( $ this -> _groups as $ group ) { if ( $ group -> has ( $ name ) ) { return $ group ; } } throw new Exception ( "Environment variable :name does not belong to any group" , array ( ':name' => $ name ) ) ; }
Find out which group a variable belongs to
1,885
public function backup ( array $ parameters ) { foreach ( $ parameters as $ name ) { $ this -> _backup [ $ name ] = $ this -> group_for_name ( $ name ) -> get ( $ name ) ; } return $ this ; }
Backup the given parameters
1,886
public function set ( array $ parameters ) { foreach ( $ parameters as $ name => $ value ) { $ this -> group_for_name ( $ name ) -> set ( $ name , $ value ) ; } return $ this ; }
Set the parameters using groups
1,887
public static function setupFromFile ( $ filePath ) { $ loggers = null ; require ( $ filePath ) ; if ( ! isset ( $ loggers ) ) { throw new LoggerManagerException ( 'The configuration file [' . $ filePath . '] must define a variable $loggers' ) ; } if ( ! is_array ( $ loggers ) ) { throw new LoggerManagerException ( 'The configuration file [' . $ filePath . '] must define a variable $loggers as an array' ) ; } self :: setupFromArray ( $ loggers ) ; }
Setup the loggers configuration with the given file
1,888
public static function setupFromArray ( array $ loggers ) { foreach ( $ loggers as $ logger ) { if ( ! isset ( $ logger [ 'class' ] ) ) { throw new LoggerManagerException ( 'Each logger configuration defined in the file [' . $ configurationFilePath . '] has to define a "class" property' ) ; } if ( ! is_string ( $ logger [ 'class' ] ) ) { throw new LoggerManagerException ( 'Each logger configuration defined in the file [' . $ configurationFilePath . '] has to define a "class" property, as a string' ) ; } if ( ! isset ( $ logger [ 'level' ] ) ) { throw new LoggerManagerException ( 'Each logger configuration defined in the file [' . $ configurationFilePath . '] has to define a "level" property' ) ; } if ( ! is_string ( $ logger [ 'level' ] ) ) { throw new LoggerManagerException ( 'Each logger configuration defined in the file [' . $ configurationFilePath . '] has to define a "level" property, as a string' ) ; } if ( ! isset ( $ logger [ 'writers' ] ) ) { throw new LoggerManagerException ( 'Each logger configuration defined in the file [' . $ configurationFilePath . '] has to define a "writers" property' ) ; } if ( ! is_array ( $ logger [ 'writers' ] ) ) { throw new LoggerManagerException ( 'Each logger configuration defined in the file [' . $ configurationFilePath . '] has to define a "writers" property, as an array' ) ; } } self :: $ _loggers = $ loggers ; }
Setup the loggers configuration with the given array
1,889
public static function findBestLoggerConfigurationForClass ( $ className ) { $ bestLogger = null ; foreach ( self :: getLoggers ( ) as $ logger ) { if ( strpos ( $ className , $ logger [ 'class' ] ) === 0 ) { $ logger [ 'length' ] = strlen ( $ logger [ 'class' ] ) ; if ( ! isset ( $ bestLogger ) ) { $ bestLogger = $ logger ; } else { if ( $ logger [ 'length' ] > $ bestLogger [ 'length' ] ) { $ bestLogger = $ logger ; } } } } return $ bestLogger ; }
Return the best logger configuration for the given class name
1,890
public function authorizeActionsOnControllerArguments ( FilterControllerArgumentsEvent $ event ) : void { foreach ( $ event -> getArguments ( ) as $ argument ) { if ( $ argument instanceof AuthorizeActionInterface ) { $ this -> authorizationChecker -> verify ( $ argument ) ; } } }
Call to this method on kernel . controller_arguments event for check right to execute actions .
1,891
public function get ( $ key ) { if ( ( $ key === NULL ) || $ key === '' ) { throw new JSONException ( 'Null key.' ) ; } $ object = $ this -> opt ( $ key ) ; if ( $ object == NULL ) { throw new JSONException ( 'JSONArray[' . JSONObject :: quote ( $ key ) . '] not found.' ) ; } return $ object ; }
Get the value associated with a key .
1,892
public function opt ( $ key ) { if ( $ key === NULL || $ key === '' || ! array_key_exists ( $ key , $ this -> map ) ) { return NULL ; } else { return $ this -> map [ $ key ] ; } }
Get an optional value associated with a key .
1,893
public function remove ( $ index ) { $ value = $ this -> opt ( $ index ) ; unset ( $ this -> map [ $ index ] ) ; return $ value ; }
Removes an index
1,894
public function toJSONObject ( $ names ) { if ( ! is_array ( $ names ) ) throw new JSONException ( 'Provided value must be an array' ) ; if ( $ names == NULL || count ( $ names ) == 0 || $ this -> length ( ) == 0 ) { return NULL ; } $ jsonObject = new JSONObject ( ) ; foreach ( $ this -> map as $ index => $ value ) { $ jsonObject -> put ( $ value , $ names [ $ index ] ) ; } return $ jsonObject ; }
Produces a JSONObject from the JSONArray
1,895
public function add ( $ job , array $ config ) { if ( empty ( $ config [ 'schedule' ] ) ) { throw new Exception ( "'schedule' is required for '$job' job" ) ; } if ( ! ( isset ( $ config [ 'command' ] ) xor isset ( $ config [ 'closure' ] ) ) ) { throw new Exception ( "Either 'command' or 'closure' is required for '$job' job" ) ; } if ( isset ( $ config [ 'command' ] ) && ( $ config [ 'command' ] instanceof Closure || $ config [ 'command' ] instanceof SerializableClosure ) ) { $ config [ 'closure' ] = $ config [ 'command' ] ; unset ( $ config [ 'command' ] ) ; if ( $ config [ 'closure' ] instanceof SerializableClosure ) { $ config [ 'closure' ] = $ config [ 'closure' ] -> getClosure ( ) ; } } $ config = array_merge ( $ this -> config , $ config ) ; $ this -> jobs [ $ job ] = $ config ; }
Add a job .
1,896
public function run ( ) { $ isUnix = ( $ this -> helper -> getPlatform ( ) === Helper :: UNIX ) ; if ( $ isUnix && ! extension_loaded ( 'posix' ) ) { throw new Exception ( 'posix extension is required' ) ; } $ scheduleChecker = new ScheduleChecker ( ) ; foreach ( $ this -> jobs as $ job => $ config ) { if ( ! $ scheduleChecker -> isDue ( $ config [ 'schedule' ] ) ) { continue ; } if ( $ isUnix ) { $ this -> runUnix ( $ job , $ config ) ; } else { $ this -> runWindows ( $ job , $ config ) ; } } }
Run all jobs .
1,897
public function updateSettings ( Request $ request ) { $ this -> authorize ( 'update' , Settings :: class ) ; Settings :: first ( ) -> update ( [ 'stripe_key' => $ request -> stripe_key ? encrypt ( $ request -> stripe_key ) : null , 'stripe_secret' => $ request -> stripe_secret ? encrypt ( $ request -> stripe_secret ) : null , ] ) ; return redirect ( ) -> route ( 'laralum::settings.index' , [ 'p' => 'Payments' ] ) -> with ( 'success' , __ ( 'laralum_payments::general.updated_settings' ) ) ; }
Save the payments settings .
1,898
public function fromFluent ( $ attributes ) { if ( is_array ( $ attributes ) ) { return $ this -> fill ( $ attributes ) ; } return $ this -> fill ( $ attributes -> toArray ( ) ) ; }
Fill the model with attributes from the object or from the array .
1,899
public function getClient ( ) { $ options = array ( 'headers' => array ( 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0' , 'Referer' => 'http://www.addic7ed.com' ) , ) ; if ( $ this -> proxy ) { $ options [ 'proxy' ] = $ this -> proxy ; } return new \ GuzzleHttp \ Client ( $ options ) ; }
Get HTTP client