idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
238,400
private function loadReferenceManyWithRepositoryMethod ( PersistentCollectionInterface $ collection ) { $ iterator = $ this -> createReferenceManyWithRepositoryMethodIterator ( $ collection ) ; $ mapping = $ collection -> getMapping ( ) ; $ documents = $ iterator -> toArray ( ) ; foreach ( $ documents as $ key => $ obj...
Populate a ReferenceMany association with a custom repository method .
238,401
public function lock ( $ document , $ lockMode ) { $ qb = $ this -> dm -> createQueryBuilder ( $ this -> class -> name ) ; $ identifier = $ this -> uow -> getDocumentIdentifier ( $ document ) ; $ lockMapping = $ this -> class -> lockMetadata ; $ qb -> update ( ) ; $ qb -> setIdentifier ( $ identifier ) ; $ qb -> attr (...
Locks document by storing the lock mode on the mapped lock attribute .
238,402
public function upsert ( $ document , $ parentPath = null ) { $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; $ changeset = $ this -> uow -> getDocumentChangeSet ( $ document ) ; if ( ! $ class -> isEmbeddedDocument ) { $ qb = $ this -> dm -> createQueryBuilder ( $ class -> name ) ; $ identifi...
Update a document if it already exists in DynamoDB or insert if it does not .
238,403
public function addToQueryCondition ( Expr $ expr ) { $ expr -> attr ( $ this -> getHashKey ( ) -> getPropertyMetadata ( ) -> name ) -> equals ( $ this -> getHashValue ( ) ) ; }
Add a conditon for this identifer s values to the provided query expression .
238,404
public function getDocument ( DocumentManager $ dm ) { $ document = $ dm -> getUnitOfWork ( ) -> tryGetByIdentifier ( $ this ) ; if ( $ document !== false ) { return $ document ; } $ document = $ dm -> getProxyFactory ( ) -> getProxy ( $ this -> class -> getName ( ) , $ this -> getArray ( ) ) ; $ dm -> getUnitOfWork ( ...
Gets a reference to the target document without actually loading it .
238,405
public function getDocumentPartial ( DocumentManager $ dm ) { $ document = $ dm -> getUnitOfWork ( ) -> tryGetByIdentifier ( $ this ) ; if ( $ document !== false ) { return $ document ; } $ document = $ this -> class -> newInstance ( ) ; $ this -> addToDocument ( $ document ) ; $ dm -> getUnitOfWork ( ) -> registerMana...
Gets a partial reference to the target document without actually loading it if the document is not yet loaded .
238,406
protected function isMetadataMethod ( string & $ subject , int $ key , string $ pattern ) { unset ( $ key ) ; if ( ! preg_match ( $ pattern , $ subject ) ) { $ subject = false ; } return ; }
Is metadata method
238,407
final protected function _nodeBuilder ( $ key , $ value = null , \ DOMNode & $ parent = null ) { if ( is_null ( $ parent ) ) { $ parent = $ this ; } if ( is_string ( $ key ) ) { if ( substr ( $ key , 0 , 1 ) === '@' and ( is_string ( $ value ) or is_numeric ( $ value ) ) ) { $ parent -> setAttribute ( substr ( $ key , ...
Dynamically and seemingly magically build nodes and append to parent
238,408
public static function fromNative ( ) { $ array = \ func_get_arg ( 0 ) ; $ items = array ( ) ; foreach ( $ array as $ item ) { if ( $ item instanceof \ Traversable || \ is_array ( $ item ) ) { $ items [ ] = static :: fromNative ( $ item ) ; } else { $ items [ ] = new StringLiteral ( \ strval ( $ item ) ) ; } } $ fixedA...
Returns a new Collection object
238,409
public function contains ( ValueObjectInterface $ object ) { foreach ( $ this -> items as $ item ) { if ( $ item -> sameValueAs ( $ object ) ) { return true ; } } return false ; }
Tells whether the Collection contains an object
238,410
private function getShieldHolding ( ) : ItemHoldingCode { if ( $ this -> weaponlikeHolding -> holdsByMainHand ( ) ) { return ItemHoldingCode :: getIt ( ItemHoldingCode :: OFFHAND ) ; } if ( $ this -> weaponlikeHolding -> holdsByOffhand ( ) ) { return ItemHoldingCode :: getIt ( ItemHoldingCode :: MAIN_HAND ) ; } if ( $ ...
Gives holding opposite to given weapon holding .
238,411
private function getFightNumberModifier ( ) : int { $ fightNumberModifier = 0 ; $ fightNumberModifier += $ this -> getFightNumberMalusByStrength ( ) ; $ fightNumberModifier += $ this -> getFightNumberMalusBySkills ( ) ; $ fightNumberModifier += $ this -> combatActions -> getFightNumberModifier ( ) ; return $ fightNumbe...
Fight number update according to a missing strength missing skill and by a combat action
238,412
private static function generateKey ( $ outputLog ) { try { Artisan :: call ( 'key:generate' , [ "--force" => true ] , $ outputLog ) ; } catch ( Exception $ e ) { return $ this -> response ( $ e -> getMessage ( ) ) ; } return $ outputLog ; }
Generate New Application Key .
238,413
public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ field = $ this -> getField ( ) ; $ table = $ this -> getTable ( ) ; if ( empty ( $ table ) ) $ table = $ params -> getDefaultTable ( ) ; $ drv = $ params -> getDriver ( ) ; if ( ! empty ( $ table ) ) { list ( $ table , $ alias ) = $ params -> resol...
Write a field name as SQL query syntax
238,414
public function setupOrganization ( User $ user ) { $ guestCreateOrganization = false ; $ invitationHash = $ this -> session -> get ( 'newInvitation' , false ) ; if ( $ guestCreateOrganization || $ invitationHash == false ) { $ organization = $ this -> createOrganization ( $ user ) ; } if ( $ invitationHash ) { $ organ...
Setup organization from signup . It chekcs if there is an invitationHash in session
238,415
public function createOrganization ( User $ user ) { $ organization = new $ this -> organizationClass ; $ organization -> setOwner ( $ user ) ; $ organization -> addUser ( $ user ) ; $ role = new Role ; $ role -> setRoles ( array ( 'ROLE_ORGANIZATION_OWNER' ) ) ; $ role -> setUser ( $ user ) ; $ role -> setOrganization...
It creates and completes a new Organization
238,416
public function addMember ( OrganizationInterface $ organization , User $ user , array $ roles ) { if ( $ organization -> getOwner ( ) === null ) { $ organization -> setOwner ( $ user ) ; } $ user -> addOrganization ( $ organization ) ; $ organization -> addUser ( $ user ) ; $ role = new Role ( ) ; $ role -> setOrganiz...
Add member to an organization with specifics roles
238,417
public function processInvitationByHash ( User $ user , $ hash ) { $ invitation = $ this -> dm -> getRepository ( 'WobbleCodeUserBundle:Invitation' ) -> findOneBy ( [ 'hash' => $ hash , 'status' => 'pending' ] ) ; if ( ! $ invitation ) { return false ; } $ organization = $ invitation -> getOrganization ( ) ; $ this -> ...
Finds an Invitation by Hash and add member if exists
238,418
public function addMemberByInvitation ( OrganizationInterface $ organization , User $ user , Invitation $ invitation ) { $ this -> addMember ( $ organization , $ user , $ invitation -> getRoles ( ) ) ; $ invitation -> setStatus ( 'accepted' ) ; $ invitation -> setTo ( $ user ) ; $ this -> dm -> persist ( $ invitation )...
Add member to an Organization using settings from invitation
238,419
public function getAdminOwner ( ) { $ repo = $ this -> dm -> getRepository ( $ this -> organizationClass ) ; return $ repo -> findOneBy ( [ 'adminOwner' => true ] ) ; }
Gets the system admin Organization
238,420
function Render ( ) { if ( ! self :: Guard ( ) -> Allow ( Action :: Read ( ) , $ this -> content ) ) { return '' ; } ContentTranslator :: Singleton ( ) -> SetContent ( $ this -> content ) ; $ module = ClassFinder :: CreateFrontendModule ( $ this -> content -> GetType ( ) ) ; $ module -> SetTreeItem ( $ this -> tree , $...
Renders the content
238,421
public function getC2Ms ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collC2MsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collC2Ms || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collC2Ms ) { $ this -> initC2Ms ( ) ; } els...
Gets an array of ChildC2M objects which contain a foreign key that references this object .
238,422
public function countM2Ps ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collM2PsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collM2Ps || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collM2Ps ) { return ...
Returns the number of related M2P objects .
238,423
public function getM2PsJoinPage ( Criteria $ criteria = null , ConnectionInterface $ con = null , $ joinBehavior = Criteria :: LEFT_JOIN ) { $ query = ChildM2PQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'Page' , $ joinBehavior ) ; return $ this -> getM2Ps ( $ query , $ con ) ; }
If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this Media is new it will return an empty collection ; or if this Media has previously been saved it will retrieve related M2Ps from storage .
238,424
protected function getCriteria ( $ entity , Constraint $ constraint , ObjectManager $ em ) { $ class = $ em -> getClassMetadata ( ClassUtils :: getClass ( $ entity ) ) ; $ fields = ( array ) $ constraint -> fields ; $ criteria = [ ] ; foreach ( $ fields as $ fieldName ) { $ criteria = $ this -> findFieldCriteria ( $ cr...
Gets criteria .
238,425
private function getResult ( $ entity , Constraint $ constraint , array $ criteria , ObjectManager $ em ) { $ filters = SqlFilterUtil :: findFilters ( $ em , ( array ) $ constraint -> filters , $ constraint -> allFilters ) ; SqlFilterUtil :: disableFilters ( $ em , $ filters ) ; $ repository = $ em -> getRepository ( C...
Get entity result .
238,426
private function isValidResult ( $ result , $ entity ) { return 0 === \ count ( $ result ) || ( 1 === \ count ( $ result ) && $ entity === ( $ result instanceof \ Iterator ? $ result -> current ( ) : current ( $ result ) ) ) ; }
Check if the result is valid .
238,427
private function findFieldCriteriaStep2 ( array & $ criteria , ObjectManager $ em , ClassMetadata $ class , $ fieldName ) : void { if ( null !== $ criteria [ $ fieldName ] && $ class -> hasAssociation ( $ fieldName ) ) { $ em -> initializeObject ( $ criteria [ $ fieldName ] ) ; $ relatedClass = $ em -> getClassMetadata...
Finds the criteria for the entity field .
238,428
protected function handleResult ( ContextInterface $ context , $ result ) { $ validated = $ this -> validateResult ( $ result ) ; if ( is_null ( $ validated ) ) { $ validated = $ result ; } if ( $ validated instanceof ContextInterface ) { $ context = $ validated ; } elseif ( ! is_null ( $ validated ) ) { $ context -> s...
Validate middleware result . Imprementer shall invoke exceptions in this method if result is not valid .
238,429
public function output ( string $ mime ) { if ( $ this -> xsendfile ) return ; $ bytes = readfile ( $ this -> filename ) ; if ( ! empty ( $ this -> length ) && $ bytes != $ this -> length ) { self :: getLogger ( ) -> warning ( "FileResponse promised to send {0} bytes but {1} were actually transfered of file {2}" , [ $ ...
Serve the file to the user
238,430
public function getPath ( array $ pathParameters = null ) { $ path = $ this -> path ; if ( ! empty ( $ this -> placeholders ) ) { foreach ( $ this -> placeholders as $ placeholder ) { $ regExp = '~\{' . $ placeholder [ 'name' ] . '(=.*?)?\}~' ; if ( $ pathParameters && array_key_exists ( $ placeholder [ 'name' ] , $ pa...
get path of route
238,431
public function setRequestMethods ( array $ requestMethods ) { $ requestMethods = array_map ( 'strtoupper' , $ requestMethods ) ; $ allowedMethods = [ 'GET' , 'POST' , 'PUT' , 'DELETE' , 'PATCH' ] ; foreach ( $ requestMethods as $ requestMethod ) { if ( ! in_array ( $ requestMethod , $ allowedMethods ) ) { throw new \ ...
set all allowed request methods for a route
238,432
public function allowsRequestMethod ( $ requestMethod ) { return empty ( $ this -> requestMethods ) || in_array ( strtoupper ( $ requestMethod ) , $ this -> requestMethods ) ; }
check whether a request method is allowed with the route
238,433
public function getPathParameter ( $ name , $ default = null ) { if ( empty ( $ this -> pathParameters ) && ! is_null ( $ this -> placeholders ) ) { $ names = array_keys ( $ this -> placeholders ) ; if ( preg_match ( '~' . $ this -> match . '~' , ltrim ( Request :: createFromGlobals ( ) -> getPathInfo ( ) , '/' ) , $ v...
get path parameter
238,434
public function redirect ( $ queryParams = [ ] , $ statusCode = 302 ) { $ request = Request :: createFromGlobals ( ) ; $ application = Application :: getInstance ( ) ; $ urlSegments = [ $ request -> getSchemeAndHttpHost ( ) ] ; if ( $ application -> getRouter ( ) -> getServerSideRewrite ( ) ) { if ( ( $ scriptName = ba...
redirect using configured redirect information if route has no redirect set redirect will lead to start page
238,435
public static function locateResource ( $ path , ContainerBuilder $ container ) { if ( 0 === stripos ( $ path , '@' ) ) { $ path = str_replace ( '\\' , '/' , $ path ) ; $ parts = explode ( '/' , $ path ) ; $ bundle = array_shift ( $ parts ) ; $ bundleName = str_replace ( '@' , '' , $ bundle ) ; $ bundleClass = null ; f...
Locates a file resource path for a given config path . Is needed in order to retrieve a bundle s directory if used .
238,436
public function emittedError ( $ value = null ) { if ( $ value === null ) { return $ this -> emittedErrorEvent ; } elseif ( $ value === true ) { $ this -> emittedErrorEvent = true ; } else { throw new \ InvalidArgumentException ( 'You cannot set the emitted ' . 'error value to false.' ) ; } }
Check or set if the exception was emitted in an error event .
238,437
protected function addFileRule ( $ attribute , $ size , $ mimes , $ count = 1 , $ isRequired = false ) { if ( $ this -> has ( $ attribute ) && is_string ( $ this -> $ attribute ) ) { $ this -> rules [ $ attribute ] = "elfinder_max:{$size}|elfinder:{$mimes}" ; } else if ( $ this -> file ( $ attribute ) && is_array ( $ t...
add file rule to rules
238,438
public function getSetting ( $ key , $ defaultValue = null ) { return $ this -> hasSetting ( $ key ) ? $ this -> settings [ $ key ] : $ defaultValue ; }
Get app setting with given key
238,439
public function get ( $ pattern , $ callback = null , $ inject = null ) { return $ this -> map ( [ 'GET' , 'HEAD' ] , $ pattern , $ callback , $ inject ) ; }
Adds a new route for the HTTP request method GET
238,440
public function post ( $ pattern , $ callback = null , $ inject = null ) { return $ this -> map ( [ 'POST' ] , $ pattern , $ callback , $ inject ) ; }
Adds a new route for the HTTP request method POST
238,441
public function put ( $ pattern , $ callback = null , $ inject = null ) { return $ this -> map ( [ 'PUT' ] , $ pattern , $ callback , $ inject ) ; }
Adds a new route for the HTTP request method PUT
238,442
public function patch ( $ pattern , $ callback = null , $ inject = null ) { return $ this -> map ( [ 'PATCH' ] , $ pattern , $ callback , $ inject ) ; }
Adds a new route for the HTTP request method PATCH
238,443
public function delete ( $ pattern , $ callback = null , $ inject = null ) { return $ this -> map ( [ 'DELETE' ] , $ pattern , $ callback , $ inject ) ; }
Adds a new route for the HTTP request method DELETE
238,444
public function head ( $ pattern , $ callback = null , $ inject = null ) { return $ this -> map ( [ 'HEAD' ] , $ pattern , $ callback , $ inject ) ; }
Adds a new route for the HTTP request method HEAD
238,445
public function trace ( $ pattern , $ callback = null , $ inject = null ) { return $ this -> map ( [ 'TRACE' ] , $ pattern , $ callback , $ inject ) ; }
Adds a new route for the HTTP request method TRACE
238,446
public function options ( $ pattern , $ callback = null , $ inject = null ) { return $ this -> map ( [ 'OPTIONS' ] , $ pattern , $ callback , $ inject ) ; }
Adds a new route for the HTTP request method OPTIONS
238,447
public function connect ( $ pattern , $ callback = null , $ inject = null ) { return $ this -> map ( [ 'CONNECT' ] , $ pattern , $ callback , $ inject ) ; }
Adds a new route for the HTTP request method CONNECT
238,448
public static function createControllerFromRoute ( Route $ route , array $ parameters = null ) { $ controllerClass = Application :: getInstance ( ) -> getApplicationNamespace ( ) . $ route -> getControllerClassName ( ) ; $ instance = new $ controllerClass ( $ route , $ parameters ) ; if ( $ method = $ instance -> route...
determines controller class name from a routes controllerString property and returns a controller instance an additional parameters array will be passed on to the constructor
238,449
protected function addEchoToJsonResponse ( JsonResponse $ r ) { if ( $ this -> isXhr && $ this -> xhrBag && $ this -> xhrBag -> get ( 'echo' ) == 1 ) { $ echo = json_decode ( $ this -> xhrBag -> get ( 'xmlHttpRequest' ) ) ; unset ( $ echo -> echo ) ; } else { if ( $ this -> request -> getMethod ( ) === 'POST' && $ this...
add an echo property to a JsonResponse if request indicates that echo was requested useful with vxJS . xhr based widgets
238,450
protected function assertEntityIsValid ( $ entity , $ scope = null ) { if ( ! $ this -> validator ) { throw new \ BadMethodCallException ( sprintf ( 'Method %s() cannot be used while validator is not configured.' , __METHOD__ ) ) ; } $ scopes = $ scope ? ( array ) $ scope : null ; $ violationList = $ this -> validator ...
assert given entity is valid on given scope .
238,451
protected function fireEvent ( $ eventName , Event $ event ) { if ( ! $ this -> eventDispatcher ) { throw new \ BadMethodCallException ( sprintf ( 'Method %s() cannot be used while event dispatcher is not configured.' , __METHOD__ ) ) ; } $ this -> eventDispatcher -> dispatch ( $ eventName , $ event ) ; }
fire given event .
238,452
protected function prepareForm ( Form $ form ) { $ form -> getElementPrototype ( ) -> class [ ] = 'form-horizontal' ; $ translator = $ form -> getTranslator ( ) ; foreach ( $ form -> controls as $ control ) { if ( $ control instanceof HiddenField ) { continue ; } elseif ( $ control instanceof Button ) { $ control -> co...
Make form and controls compatible with Twitter Bootstrap
238,453
public static function rectangle ( Point $ corner , $ width , $ height , $ ccw = false ) { $ points = new Points ( $ corner ) ; $ points -> addPoint ( $ corner ) ; $ points -> addPoint ( $ corner ) -> translateX ( $ width ) ; $ points -> addPoint ( $ corner ) -> translate ( $ width , $ height ) ; $ points -> addPoint (...
Calculates the points for a rectangle .
238,454
public static function polygon ( Point $ center , $ n , $ radius , $ ccw = false ) { return self :: star ( $ center , $ n , $ radius , [ ] , $ ccw ) ; }
Calculates the points for a regular polygon .
238,455
public static function star ( Point $ center , $ n , $ radius , $ starRadii = [ ] , $ ccw = false ) { $ points = new Points ( $ center ) ; if ( ! is_array ( $ starRadii ) ) { $ starRadii = [ $ starRadii ] ; } $ radii = array_merge ( [ $ radius ] , $ starRadii ) ; $ count = count ( $ radii ) ; $ delta = deg2rad ( 360 ) ...
Calculates the Points for a regular star polygon .
238,456
public static function sector ( Point $ center , Angle $ start , Angle $ stop , $ radius , $ ccw = false ) { $ points = new Points ( $ center ) ; $ points -> addPoint ( $ center ) ; $ points -> addPoint ( $ center ) -> translateX ( $ radius ) -> rotate ( $ center , $ start ) ; $ points -> addPoint ( $ center ) -> trans...
Calculates the points for a sector of a circle .
238,457
public static function ringSector ( Point $ center , Angle $ start , Angle $ stop , $ radius , $ innerRadius , $ ccw = false ) { $ points = new Points ( $ center , false ) ; if ( $ ccw ) { $ swap = $ start ; $ start = $ stop ; $ stop = $ swap ; } $ points -> addPoint ( $ center ) -> translateX ( $ radius ) -> rotate ( ...
Calculates the points for a sector of a ring .
238,458
public static function roundedRectangle ( Point $ corner , $ width , $ height , $ radius , $ ccw = false ) { $ points = new Points ( $ corner , false ) ; $ points -> addPoint ( $ corner ) -> translateX ( $ width - $ radius ) ; $ points -> addPoint ( $ corner ) -> translate ( $ width , $ radius ) ; $ points -> addPoint ...
Calculates the points for a rounded rectangle .
238,459
public function scale ( Point $ center , $ factor ) { foreach ( $ this -> points as $ point ) { $ point -> scale ( $ center , $ factor ) ; } $ this -> start -> scale ( $ center , $ factor ) ; return $ this ; }
Scales points .
238,460
public function scaleX ( Point $ center , $ factor ) { foreach ( $ this -> points as $ point ) { $ point -> scaleX ( $ center , $ factor ) ; } $ this -> start -> scaleX ( $ center , $ factor ) ; $ this -> reverseIfCcw ( $ factor < 0 ) ; return $ this ; }
Scales points along the X - axis .
238,461
public function translate ( $ deltaX , $ deltaY ) { foreach ( $ this -> points as $ point ) { $ point -> translate ( $ deltaX , $ deltaY ) ; } $ this -> start -> translate ( $ deltaX , $ deltaY ) ; return $ this ; }
Translates points .
238,462
public function translateX ( $ deltaX ) { foreach ( $ this -> points as $ point ) { $ point -> translateX ( $ deltaX ) ; } $ this -> start -> translateX ( $ deltaX ) ; return $ this ; }
Translates points along the X - axis .
238,463
public function translateY ( $ deltaY ) { foreach ( $ this -> points as $ point ) { $ point -> translateY ( $ deltaY ) ; } $ this -> start -> translateY ( $ deltaY ) ; return $ this ; }
Translates points along the Y - axis .
238,464
public static function getLogger ( $ module = "" ) { if ( is_object ( $ module ) ) $ module = get_class ( $ module ) ; elseif ( empty ( $ module ) || strtoupper ( $ module ) === "ROOT" ) $ module = "" ; $ module = trim ( str_replace ( '\\' , '.' , $ module ) , ". \\" ) ; if ( ! isset ( self :: $ module_loggers [ $ modu...
Get a logger for a specific module .
238,465
public static function resetGlobalState ( ) { foreach ( self :: $ module_loggers as $ logger ) $ logger -> removeLogWriters ( ) ; self :: $ module_loggers = [ ] ; self :: $ accept_mode = self :: MODE_ACCEPT_MOST_SPECIFIC ; }
This method will reset all global state in the Logger object . It will remove all writers from all loggers and then remove all loggers . Note that this will not remove existing logger instances from other objects - this is why the writers are removed .
238,466
public function setLevel ( string $ level ) { if ( ! defined ( LogLevel :: class . '::' . strtoupper ( $ level ) ) ) throw new \ DomainException ( "Invalid log level: $level" ) ; $ this -> level = $ level ; $ this -> level_num = self :: $ LEVEL_NUMERIC [ $ level ] ; return $ this ; }
Set the log level for this module . Any log messages with a severity lower than this threshold will not bubble up .
238,467
public static function fillPlaceholders ( string $ message , array $ context ) { $ message = ( string ) $ message ; foreach ( $ context as $ key => $ value ) { $ placeholder = '{' . $ key . '}' ; $ strval = null ; $ pos = 0 ; while ( ( $ pos = strpos ( $ message , $ placeholder , $ pos ) ) !== false ) { $ strval = $ st...
Fill the place holders in the message with values from the context array
238,468
public static function getLevelNumeric ( string $ level ) { return isset ( self :: $ LEVEL_NUMERIC [ $ level ] ) ? self :: $ LEVEL_NUMERIC [ $ level ] : 0 ; }
Get the severity number for a specific LogLevel .
238,469
public function get ( $ connection , $ cache = true ) { if ( ! is_string ( $ connection ) ) { throw new BadTypeException ( $ connection , 'string' ) ; } if ( ! isset ( $ this -> instances [ $ connection ] ) or ! $ cache ) { if ( ! isset ( $ this -> connectionSettings [ $ connection ] ) ) { throw new UnknownNamedConnect...
Get the singleton pg connection
238,470
public function remove ( Resource $ resource ) { $ cnt = 0 ; if ( false !== $ key = array_search ( $ resource , $ this -> instances , true ) ) { unset ( $ this -> instances [ $ key ] ) ; $ cnt ++ ; } return $ cnt ; }
Remove a resource from the multiton cache
238,471
protected function sendOne ( $ dry_run ) { $ message = $ this -> messages [ 0 ] ; $ adapter = $ this -> getAdapter ( ) ; $ adapter -> setEndpoint ( self :: SINGLE_ENDPOINT ) ; $ adapter -> setParameters ( array ( 'user' => $ this -> config [ 'user' ] , 'password' => $ this -> config [ 'password' ] , 'serviceid' => $ th...
We use smspush for sending single messages .
238,472
public function restore ( string $ key ) : self { if ( array_key_exists ( $ key , $ this -> original ) ) { ini_set ( $ key , $ this -> original [ $ key ] ) ; } return $ this ; }
Restore a previous ini setting .
238,473
public function cleanup ( ) : self { foreach ( $ this -> original as $ key => $ value ) { ini_set ( $ key , $ value ) ; } $ this -> original = [ ] ; return $ this ; }
Restore the previous ini settings .
238,474
public function getType ( $ name ) { if ( false === $ this -> hasType ( $ name ) ) { throw new InvalidArgumentException ( sprintf ( 'The type "%s" was not found.' , $ name ) ) ; } if ( isset ( $ this -> loaded [ $ name ] ) ) { return $ this -> loaded [ $ name ] ; } $ fqcn = $ this -> types [ $ name ] ; $ type = new $ f...
Gets a type object .
238,475
public function addType ( $ name , $ fqcn ) { if ( true === $ this -> hasType ( $ name ) ) { throw new InvalidArgumentException ( sprintf ( 'The type "%s" already exists.' , $ name ) ) ; } return $ this -> setType ( $ name , $ fqcn ) ; }
Adds a type object .
238,476
public function overrideType ( $ name , $ fqcn ) { if ( false === $ this -> hasType ( $ name ) ) { throw new InvalidArgumentException ( sprintf ( 'The type "%s" was not found.' , $ name ) ) ; } return $ this -> setType ( $ name , $ fqcn ) ; }
Overrides a type object with new class .
238,477
public function setInvitedLink ( TimelineLinkEvent $ event ) : void { $ action = $ event -> getAction ( ) ; if ( 'invited' != $ action -> getVerb ( ) ) { return ; } $ event = $ action -> getComponent ( 'indirectComplement' ) -> getData ( ) ; $ event -> setLink ( $ this -> url_generator -> generate ( 'bkstg_event_read' ...
Set the link for invited actions .
238,478
public function setScheduledLink ( TimelineLinkEvent $ event ) : void { $ action = $ event -> getAction ( ) ; if ( 'scheduled' != $ action -> getVerb ( ) ) { return ; } $ production = $ action -> getComponent ( 'indirectComplement' ) -> getData ( ) ; $ schedule = $ action -> getComponent ( 'directComplement' ) -> getDa...
Set the link for scheduled actions .
238,479
public function updateEntry ( $ package , $ theme ) { $ this -> verifyCommand ( $ package ) ; $ lines = file ( $ this -> config ) ; $ config = $ this -> compactConfig ( $ package ) ; $ lines = $ this -> updateConfigDetails ( $ theme , $ lines , $ config ) ; $ this -> file -> delete ( $ this -> config ) ; $ this -> file...
Update the config with the color values for easy retrieval
238,480
public function TopMost ( ) { $ sql = Access :: SqlBuilder ( ) ; $ tbl = Page :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tbl -> Field ( 'Site' ) , $ sql -> Value ( $ this -> site -> GetID ( ) ) ) -> And_ ( $ sql -> IsNull ( $ tbl -> Field ( 'Parent' ) ) ) -> And_ ( $ sql -> IsNull ( $ tbl -> Field ( 'Pr...
Gets the first and root page of the site
238,481
public function connect ( $ credentials = [ ] ) { if ( $ diff = array_diff ( array_keys ( $ this -> settings ) , array_keys ( $ credentials ) ) ) { throw new \ Exception ( "Missing credentials, the following fields are missing " . implode ( '/' , $ diff ) ) ; } $ this -> settings = array_merge ( $ this -> settings , $ ...
Open a connection to a mail server .
238,482
public function getMailbox ( ) { $ mailbox = str_replace ( "{" . $ this -> settings [ 'server' ] . "}" , '' , $ this -> mailbox ) ; $ mailbox = ( substr ( $ mailbox , 0 , 6 ) == 'INBOX.' ) ? substr ( $ mailbox , - 6 ) : $ mailbox ; return $ mailbox ; }
Return the name of the current mailbox .
238,483
public function subscribeMailbox ( $ name = '' ) { if ( empty ( $ name ) ) { return false ; } $ name = imap_utf7_encode ( $ name ) ; return imap_subscribe ( $ this -> conn , "{" . $ this -> settings [ 'server' ] . "}INBOX." . $ name ) ; }
Subscribe to a mailbox .
238,484
public function getMessageInformation ( $ id = '' ) { $ message = [ ] ; if ( is_array ( $ this -> messages ) == true ) { foreach ( $ this -> messages as $ msg ) { if ( $ msg [ 'index' ] == $ id ) { return $ msg ; } } } return $ message ; }
Return message information without reading it from the server
238,485
public function getMessage ( $ id = '' ) { $ message = [ ] ; if ( is_array ( $ this -> messages ) == true ) { foreach ( $ this -> messages as $ msg ) { if ( $ msg [ 'index' ] == $ id ) { $ message = $ msg ; break ; } } } if ( is_array ( $ message ) === true ) { $ message [ 'body' ] = quoted_printable_decode ( imap_fetc...
Return a message based on its index in the mailbox .
238,486
public function readMailbox ( ) { $ msg_cnt = imap_num_msg ( $ this -> conn ) ; $ messages = [ ] ; for ( $ i = 1 ; $ i <= $ msg_cnt ; $ i ++ ) { $ header = imap_headerinfo ( $ this -> conn , $ i ) ; $ messages [ ] = [ 'index' => trim ( $ header -> Msgno ) , 'header' => $ header , 'structure' => imap_fetchstructure ( $ ...
Retrieve a list of message in the mailbox .
238,487
private function loadVersion ( ) { try { $ this -> dao = $ this -> db -> getDAO ( DBVersion :: class ) ; $ this -> db_version = $ this -> dao -> get ( QB :: where ( [ "module" => $ this -> module ] ) , QB :: order ( [ 'migration_date' => 'DESC' ] ) ) ? : new NullVersion ; } catch ( TableNotExistsException $ e ) { if ( ...
Load the current version from the database
238,488
public function migrateTo ( int $ target_version ) { if ( $ this -> max_version === null ) $ this -> scanMigrations ( ) ; $ current_version = $ this -> getCurrentVersion ( ) ; $ trajectory = $ this -> plan ( $ current_version , $ target_version ) ; $ db = $ this -> db ; foreach ( $ trajectory as $ migration ) { $ migra...
Perform a migration from the current version to the target version
238,489
protected function plan ( int $ from , int $ to ) { $ migrations = [ ] ; if ( $ from === $ to ) return $ migrations ; $ is_downgrade = $ to < $ from ; $ reachable = $ this -> migrations [ $ from ] ?? [ ] ; if ( ! $ is_downgrade ) $ reachable = array_reverse ( $ reachable , true ) ; foreach ( $ reachable as $ direct_to ...
Plan a path through available migrations to reach a specified version from another version . This is always done in one direction opportunistically . This means that when downgrading no intermediate upgrades are performed even if they may result in shorter path .
238,490
protected function AddUniqueSubmit ( $ label ) { $ name = $ label . '-' . $ this -> Content ( ) -> GetID ( ) ; $ fullLabel = $ this -> Label ( $ label ) ; $ this -> AddSubmit ( $ name , Trans ( $ fullLabel ) ) ; }
Adds a submit button with a unique name
238,491
public function toArray ( ) { $ class = $ this -> get ( ) ; $ class = ( array ) $ class ; foreach ( $ class as $ key => $ value ) { if ( is_object ( $ value ) ) { $ class [ $ key ] = ( new static ( $ value ) ) -> toArray ( ) ; } } return $ class ; }
Recursively convert our object into an array .
238,492
protected function validateTypes ( Dictionary $ types , $ path = "" ) { $ spath = empty ( $ path ) ? "" : $ path . "." ; foreach ( $ types as $ key => $ value ) { $ kpath = $ spath . $ key ; if ( $ value instanceof Dictionary ) { $ this -> validateTypes ( $ value , $ kpath ) ; } elseif ( is_string ( $ value ) ) { $ typ...
Validate that all provided types are actually type validators
238,493
public function setType ( $ key , $ type ) { $ args = func_get_args ( ) ; $ type = array_pop ( $ args ) ; if ( ! ( $ type instanceof Validator ) ) $ type = new Validator ( $ type ) ; if ( $ this -> types -> has ( $ args ) ) { $ old_type = $ this -> types -> get ( $ args ) ; if ( $ old_type != $ type ) throw new \ Logic...
Add a type for a parameter
238,494
public function set ( $ key , $ value ) { if ( is_array ( $ key ) && $ value === null ) $ args = $ key ; else $ args = func_get_args ( ) ; $ path = $ args ; $ value = array_pop ( $ path ) ; $ type = $ this -> types -> dget ( $ path ) ; $ kpath = implode ( '.' , $ path ) ; if ( $ type === null ) { $ cpy = $ path ; while...
Set a value after type checking
238,495
public function & dget ( $ key , $ default = null ) { $ args = WF :: flatten_array ( func_get_args ( ) ) ; if ( func_num_args ( ) > 1 ) { $ default = array_pop ( $ args ) ; if ( ! ( $ default instanceof DefVal ) ) $ default = new DefVal ( $ default ) ; $ args [ ] = $ default ; } $ result = parent :: dget ( $ args , nul...
We override dget as dget returns a reference allowing the TypedDictionary to be modified from the outside . This avoids the checks so this needs to be disallowed .
238,496
public function addAll ( $ values ) { foreach ( $ values as $ key => $ value ) $ this -> set ( $ key , $ value ) ; return $ this ; }
Add all provided values checking their types
238,497
public static function wrap ( array & $ values ) { $ types = new Dictionary ; self :: determineTypes ( $ values , $ types ) ; return new TypedDictionary ( $ types , $ values ) ; }
Customize wrapping of the TypedDictionary - the wrapped array can still be modified externally so we need to make sure the appropriate types are propagated
238,498
private function globRecursive ( $ pattern ) { $ paths = glob ( $ pattern ) ; foreach ( $ paths as $ path ) { if ( strpos ( $ path , '.' ) === false ) { $ paths = array_merge ( $ paths , $ this -> globRecursive ( $ path . '/*' ) ) ; } } return $ paths ; }
watch out can be slow! 4 . 75s for 20k paths
238,499
public function get ( $ key ) { if ( $ this -> frontHas ( $ key ) ) { return $ this -> front -> get ( $ key ) ; } return $ this -> back -> get ( $ key ) ; }
Either end get ok is ok