idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
48,700
public function xml2json ( ) : void { $ xml = simplexml_load_string ( $ this -> xmlData , NULL , LIBXML_NOCDATA ) ; $ this -> jsonData = json_encode ( $ xml ) ; }
Convert XML to JSON
48,701
public function indexAction ( ) { $ em = $ this -> getDoctrineManager ( ) ; $ entities = $ em -> getRepository ( 'BisonLabSakonninBundle:MessageType' ) -> findAll ( ) ; $ parents = $ em -> createQueryBuilder ( ) -> select ( 'mt' ) -> from ( 'BisonLab\SakonninBundle\Entity\MessageType' , 'mt' ) -> where ( 'mt.parent is ...
Lists all MessageType entities .
48,702
public function createAction ( Request $ request ) { $ entity = new MessageType ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; $ form -> handleRequest ( $ request ) ; $ data = $ form -> getData ( ) ; if ( ! $ data -> getParent ( ) && ! isset ( $ request -> request -> get ( $ form -> getName ( ) ) [ 'create_gr...
Creates a new MessageType entity .
48,703
private function createCreateForm ( MessageType $ entity ) { $ form = $ this -> createForm ( MessageTypeType :: class , $ entity , array ( 'action' => $ this -> generateUrl ( 'messagetype_create' ) , 'method' => 'POST' , ) ) ; $ this -> _addFunctionsToForm ( $ form ) ; $ form -> add ( 'create_group' , CheckboxType :: c...
Creates a form to create a MessageType entity .
48,704
public function newAction ( ) { $ entity = new MessageType ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return $ this -> render ( 'BisonLabSakonninBundle:MessageType:edit.html.twig' , array ( 'entity' => $ entity , 'edit_form' => $ form -> createView ( ) , ) ) ; }
Displays a form to create a new MessageType entity .
48,705
private function createEditForm ( MessageType $ entity ) { $ form = $ this -> createForm ( MessageTypeType :: class , $ entity , array ( 'action' => $ this -> generateUrl ( 'messagetype_update' , array ( 'id' => $ entity -> getId ( ) ) ) , 'method' => 'PUT' , ) ) ; $ this -> _addFunctionsToForm ( $ form ) ; $ form -> a...
Creates a form to edit a MessageType entity .
48,706
public function updateAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrineManager ( ) ; $ entity = $ em -> getRepository ( 'BisonLabSakonninBundle:MessageType' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find MessageType entity.' ) ; } $ deleteForm = $ thi...
Edits an existing MessageType entity .
48,707
public function deleteAction ( Request $ request , $ id ) { $ form = $ this -> createDeleteForm ( $ id ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrineManager ( ) ; $ entity = $ em -> getRepository ( 'BisonLabSakonninBundle:MessageType' ) -> find ( $ id ) ; if ( ! ...
Deletes a MessageType entity .
48,708
public function register ( $ event , callable $ listener , $ priority = null ) { foreach ( ( array ) $ event as $ e ) { $ this -> registerListener ( $ e , $ listener , $ priority ) ; } return $ this ; }
Adds listener to single event or array of events
48,709
protected function resolvePseudoCallable ( $ callableOrArray ) { if ( is_array ( $ callableOrArray ) ) { $ this -> dereferenceArray ( $ callableOrArray ) ; } if ( is_callable ( $ callableOrArray ) ) { return $ callableOrArray ; } else { throw new LogicException ( Message :: get ( Message :: CALLABLE_INVALID , $ callabl...
Resolve a fake callable to a real one
48,710
protected function resolveCallableArguments ( callable $ callable , array $ providedArguments ) { if ( is_object ( $ callable ) && ! $ callable instanceof \ Closure ) { $ reflector = new \ ReflectionClass ( $ callable ) ; $ method = $ reflector -> getMethod ( '__invoke' ) ; } elseif ( is_array ( $ callable ) ) { $ refl...
Resolve arguments for a callable
48,711
protected function getObjectByClassname ( $ classname ) { if ( isset ( $ this -> mappings [ $ classname ] ) ) { $ classname = $ this -> mappings [ $ classname ] ; if ( false !== ( $ ref = $ this -> isReference ( $ classname ) ) ) { $ classname = $ this -> getReferenceValue ( $ ref ) ; if ( is_object ( $ classname ) ) {...
Get an object base on provided classname
48,712
protected function createServiceObject ( $ id , array $ arguments ) { $ def = & $ this -> services [ $ id ] [ 'class' ] ; $ class = $ def [ 0 ] ; $ args = empty ( $ arguments ) ? ( isset ( $ def [ 1 ] ) ? $ def [ 1 ] : [ ] ) : $ arguments ; try { if ( is_object ( $ class ) ) { if ( $ class instanceof \ Closure ) { retu...
Create service object from service definition
48,713
protected function runDefinedMethods ( $ id , $ service ) { try { if ( isset ( $ this -> services [ $ id ] [ 'methods' ] ) ) { $ methods = $ this -> services [ $ id ] [ 'methods' ] ; foreach ( $ methods as $ method ) { if ( ! is_array ( $ method ) || ! isset ( $ method [ 0 ] ) || ! is_string ( $ method [ 0 ] ) ) { thro...
Initialize service object by runing its defined methods
48,714
public function addMember ( GroupMemberInterface $ member ) { if ( $ this -> members -> contains ( $ member ) ) { throw new \ InvalidArgumentException ( 'This entity is already a member of this group' ) ; } $ this -> members -> add ( $ member ) ; }
Add a member to the collection .
48,715
public function removeMember ( GroupMemberInterface $ member ) { if ( ! $ this -> hasMember ( $ member ) ) { throw new \ InvalidArgumentException ( 'Trying to remove a member that is not in that group' ) ; } $ this -> members -> removeElement ( $ member ) ; }
Remove a member from the collection .
48,716
public function addChild ( GroupInterface $ child ) { if ( $ this -> children -> contains ( $ child ) ) { throw new \ InvalidArgumentException ( 'This entity is already a child of this group' ) ; } $ this -> children -> add ( $ child ) ; }
Add a child group to the collection .
48,717
public function removeChild ( GroupInterface $ child ) { if ( ! $ this -> hasChild ( $ child ) ) { throw new \ InvalidArgumentException ( 'Trying to remove a non existing child group' ) ; } $ this -> children -> removeElement ( $ child ) ; }
Remove a child group from the collection .
48,718
public function find ( Request $ request , array $ routes ) { foreach ( $ routes as $ route ) { if ( ! $ this -> matchMethod ( $ request , $ route ) ) { continue ; } if ( ! $ this -> matchContentType ( $ request , $ route ) ) { continue ; } if ( ! $ this -> matchFilters ( $ route ) ) { continue ; } $ routeMatches = $ t...
Finds a route in matching its pattern with a uri .
48,719
public function getName ( ) { if ( ! $ this -> name ) { $ this -> name = $ this -> utils ( ) -> whichModule ( $ this ) ; } return $ this -> name ; }
Retrieve module name for setup service
48,720
public function install ( $ version = null , array $ options = array ( ) ) { $ module = $ this -> utils ( ) -> whichModule ( $ this ) ; if ( $ version === null ) { $ version = $ this -> utils ( ) -> getModuleVersion ( $ module ) ; if ( ! $ version ) { throw new MissingParameterException ( 'Parameter version is missing ...
Install module and its dependencies
48,721
public function update ( array $ options = array ( ) ) { $ module = $ this -> utils ( ) -> whichModule ( $ this ) ; return $ this -> utils ( ) -> update ( $ module , $ options ) ; }
Update module and its dependencies
48,722
public function upgrade ( $ from , array $ options = array ( ) ) { $ to = $ this -> utils ( ) -> getModuleVersion ( $ this -> getName ( ) ) ; if ( SoftwareVersion :: compare ( $ to , $ from ) <= 0 ) { throw new Exception \ IllegalVersionException ( sprintf ( 'Unable to upgrade %s to version %s' , $ this -> getName ( ) ...
Upgrade module from previous version
48,723
protected function utils ( ) { if ( ! $ this -> utils ) { $ this -> utils = $ this -> getServiceLocator ( ) -> get ( 'valu_setup.setup_utils' ) ; } return $ this -> utils ; }
Direct access to service utilities
48,724
public function listen ( $ channels ) { $ channels = is_array ( $ channels ) ? $ channels : array ( $ channels ) ; foreach ( $ channels as $ channel ) { $ channel = preg_replace ( "/[^a-zA-Z\._:]/" , '' , $ channel ) ; $ this -> query ( new Raw ( "LISTEN {$channel}" ) ) ; } }
Subscribe to a postgres channel
48,725
public function quote ( $ value , array $ modifiers = [ ] ) { if ( is_null ( $ value ) ) { $ value = 'NULL' ; } elseif ( is_bool ( $ value ) ) { $ value = $ value ? 'TRUE' : 'FALSE' ; } elseif ( is_int ( $ value ) ) { $ value = ( string ) $ value ; } elseif ( $ value instanceof SqlInterface ) { $ value = $ value -> par...
Return a value made safe for insertion into a database
48,726
public function getParameter ( $ parameter ) { self :: isParameterAllowed ( $ parameter ) ; $ value = $ this -> query ( new Raw ( "SHOW {$parameter}" ) ) -> fetch ( Result :: FETCH_SINGLE ) ; return ( $ value === 'true' or $ value === 'false' ) ? \ Bond \ boolval ( $ value ) : $ value ; }
Get a postgres runtime parameter
48,727
public function setParameter ( $ parameter , $ value , $ restorePoint = self :: PREVIOUS , $ type = self :: SESSION ) { if ( ! is_scalar ( $ value ) ) { throw new BadTypeException ( $ value , 'scalar' ) ; } self :: isParameterAllowed ( $ parameter ) ; if ( ! in_array ( $ type , array ( self :: SESSION , self :: LOCAL )...
Set a postgres runtime parameter
48,728
public static function factory ( array $ record ) { if ( ! array_key_exists ( 'fields' , $ record ) ) { throw new InvalidArgumentException ( "Missing 'fields' index in record array" ) ; } $ fields = array_map ( array ( 'HAB\Pica\Record\Field' , 'factory' ) , $ record [ 'fields' ] ) ; $ type = null ; $ typePredicate = F...
Return a new record based on its array representation .
48,729
public function append ( Field $ field ) { if ( in_array ( $ field , $ this -> _fields , true ) ) { throw new InvalidArgumentException ( "{$this} already contains {$field}" ) ; } $ this -> _fields [ ] = $ field ; }
Append a field to the record .
48,730
public function sort ( ) { usort ( $ this -> _fields , function ( Field $ fieldA , Field $ fieldB ) { return strcmp ( $ fieldA -> getShorthand ( ) , $ fieldB -> getShorthand ( ) ) ; } ) ; }
Sort the fields of the record .
48,731
public function setFields ( array $ fields ) { $ this -> _fields = array ( ) ; foreach ( $ fields as $ field ) { $ this -> append ( $ field ) ; } }
Set the record fields .
48,732
public function getMaximumOccurrenceOf ( $ tag ) { if ( ! preg_match ( Field :: TAG_RE , $ tag ) ) { throw new InvalidArgumentException ( "Invalid field tag: {$tag}" ) ; } return array_reduce ( $ this -> getFields ( $ tag ) , function ( $ maxOccurrence , Field $ field ) { if ( $ field -> getOccurrence ( ) > $ maxOccurr...
Return the maximum occurrence value of a field .
48,733
public function getFirstMatchingField ( $ selector ) { $ fields = $ this -> getFields ( $ selector ) ; if ( empty ( $ fields ) ) { return null ; } else { return reset ( $ fields ) ; } }
Return the first field that matches a selector .
48,734
public function load ( $ helperName , $ directory = null ) : bool { $ helperName = strtolower ( str_replace ( array ( '_helper' , '.php' ) , '' , $ helperName ) . '_helper' ) ; $ directories = ( is_null ( $ directory ) ? $ this -> helperPaths : array ( $ directory ) ) ; if ( isset ( $ this -> helpers [ $ helperName ] )...
Load a helper .
48,735
public function removeHelperPath ( $ directory ) { if ( ( $ key = array_search ( $ directory , $ this -> helperPaths ) ) !== false ) { unset ( $ this -> helperPaths [ $ key ] ) ; } }
Remove a path where helpers can be found
48,736
public function setType ( $ type ) { if ( ! in_array ( $ type , array ( self :: AUTO , self :: ISBN10 , self :: ISBN13 ) ) ) { throw new Zend_Validate_Exception ( 'Invalid ISBN type' ) ; } $ this -> _type = $ type ; return $ this ; }
Set allowed ISBN type .
48,737
public function setBootstrapBrandImage ( string $ link , int $ size = 30 ) : void { $ this -> bootstrapOptions [ 'brand' ] [ 'image' ] [ 'link' ] = $ link ; $ this -> bootstrapOptions [ 'brand' ] [ 'image' ] [ 'size' ] = $ size ; }
Set Bootstrap brand image
48,738
public function getReflectionClass ( $ class , $ throw = true ) { if ( ! $ class = $ this -> getParameterBag ( ) -> resolveValue ( $ class ) ) { return ; } if ( isset ( self :: $ internalTypes [ $ class ] ) ) { return null ; } $ resource = null ; try { if ( isset ( $ this -> classReflectors [ $ class ] ) ) { $ classRef...
Retrieves the requested reflection class and registers it for resource tracking .
48,739
public function fileExists ( $ path , $ trackContents = true ) { $ exists = file_exists ( $ path ) ; if ( ! $ this -> trackResources || $ this -> inVendors ( $ path ) ) { return $ exists ; } if ( ! $ exists ) { $ this -> addResource ( new FileExistenceResource ( $ path ) ) ; return $ exists ; } if ( is_dir ( $ path ) )...
Checks whether the requested file or directory exists and registers the result for resource tracking .
48,740
public static function getServiceConditionals ( $ value ) { $ services = array ( ) ; if ( is_array ( $ value ) ) { foreach ( $ value as $ v ) { $ services = array_unique ( array_merge ( $ services , self :: getServiceConditionals ( $ v ) ) ) ; } } elseif ( $ value instanceof Reference && ContainerInterface :: IGNORE_ON...
Returns the Service Conditionals .
48,741
public static function getInitializedConditionals ( $ value ) { $ services = array ( ) ; if ( is_array ( $ value ) ) { foreach ( $ value as $ v ) { $ services = array_unique ( array_merge ( $ services , self :: getInitializedConditionals ( $ v ) ) ) ; } } elseif ( $ value instanceof Reference && ContainerInterface :: I...
Returns the initialized conditionals .
48,742
public static function hash ( $ value ) { $ hash = substr ( base64_encode ( hash ( 'sha256' , serialize ( $ value ) , true ) ) , 0 , 7 ) ; return str_replace ( array ( '/' , '+' ) , array ( '.' , '_' ) , strtolower ( $ hash ) ) ; }
Computes a reasonably unique hash of a value .
48,743
public function getExceptions ( \ Throwable $ exception ) : array { $ exc = $ exception ; do { $ exc_data = [ 'value' => $ this -> serializer -> serialize ( $ exc -> getMessage ( ) ) , 'type' => get_class ( $ exc ) , ] ; $ trace = $ exc -> getTrace ( ) ; $ frame_where_exception_thrown = [ 'file' => $ exc -> getFile ( )...
Generate exceptions data for Sentry
48,744
public function getStackTraceFrames ( array $ trace ) : array { return \ Raven_Stacktrace :: get_stack_info ( $ trace , $ this -> client -> trace , [ ] , $ this -> client -> message_limit , $ this -> client -> getPrefixes ( ) , $ this -> client -> getAppPath ( ) , $ this -> client -> getExcludedAppPaths ( ) , $ this ->...
Generate StackTrace frames for Sentry
48,745
public function cleanBacktrace ( array $ trace ) : array { $ firstNotRemovable = 0 ; foreach ( $ trace as $ index => $ item ) { if ( ! $ this -> shouldRemoveStack ( $ item ) ) { $ firstNotRemovable = $ index ; break ; } } $ trace = array_slice ( $ trace , $ firstNotRemovable ? : 0 ) ; return $ trace ; }
Remove stacks until the stack is from outside the logging context based on namespaces to ignore .
48,746
private function shouldRemoveStack ( array $ stack ) : bool { if ( empty ( $ stack [ 'class' ] ) ) { return false ; } foreach ( $ this -> ignoreBacktraceNamespaces as $ namespace ) { if ( 0 === strpos ( $ stack [ 'class' ] , $ namespace ) ) { return true ; } } return false ; }
Should the stack be removed?
48,747
function post ( $ url , $ parameters = array ( ) , $ multi = false ) { $ response = $ this -> oAuthRequest ( $ url , 'POST' , $ parameters , $ multi ) ; if ( $ this -> format === 'json' && $ this -> decode_json ) { return json_decode ( $ response , true ) ; } return $ response ; }
POST wreapper for oAuthRequest .
48,748
function delete ( $ url , $ parameters = array ( ) ) { $ response = $ this -> oAuthRequest ( $ url , 'DELETE' , $ parameters ) ; if ( $ this -> format === 'json' && $ this -> decode_json ) { return json_decode ( $ response , true ) ; } return $ response ; }
DELTE wrapper for oAuthReqeust .
48,749
public static function has ( string $ name , ? string $ syntax = null ) { if ( isset ( $ _SESSION [ 'application' ] [ 'with' ] [ $ name ] ) ) { $ _SESSION [ 'application' ] [ 'flash' ] [ 'used' ] = true ; $ name = $ _SESSION [ 'application' ] [ 'with' ] [ $ name ] ; return $ syntax ? str_replace ( ':message' , $ name ,...
Check if variables exists
48,750
public function getService ( $ service ) { if ( ! isset ( $ this -> services [ $ service ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Service %s not found' , $ service ) ) ; } return $ this -> services [ $ service ] ; }
Getter of a service
48,751
public function consume ( $ queueAlias , $ timeout = 0 ) { $ queues = is_array ( $ queueAlias ) ? $ this -> queueAliasResolver -> getQueues ( $ queueAlias ) : $ this -> queueAliasResolver -> getQueue ( $ queueAlias ) ; $ payloadArray = $ this -> redis -> blPop ( $ queues , $ timeout ) ; if ( empty ( $ payloadArray ) ) ...
Retrieve queue value with a defined timeout .
48,752
protected function isSelected ( ) : bool { $ key = $ this -> choices [ $ this -> line ] [ 'key' ] ; return array_key_exists ( $ key , $ this -> selections ) ; }
Check for current line
48,753
protected function checkMissingParentsDependencies ( array $ choice ) : array { $ missing = [ ] ; $ depends = ( array ) $ choice [ 'depends' ] ; foreach ( $ depends as $ dependency ) { if ( ! isset ( $ this -> selections [ $ dependency ] ) ) { foreach ( $ this -> choices as $ choice ) { if ( is_array ( $ choice ) && $ ...
Make sure all dependencies are already selected
48,754
public static function addPsr4 ( $ prefix , $ base_dir , $ prepend = false ) { $ prefix = trim ( $ prefix , '\\' ) . '\\' ; $ base_dir = rtrim ( $ base_dir , DIRECTORY_SEPARATOR ) . '/' ; if ( false === isset ( static :: $ psr4 [ $ prefix ] ) ) { static :: $ psr4 [ $ prefix ] = [ ] ; } if ( true === $ prepend ) { array...
Adds a base directory for a namespace prefix using the PSR - 4 standard .
48,755
public static function add ( $ prefix , $ base_dir , $ prepend = false ) { $ prefix = trim ( $ prefix , '\\' ) . '\\' ; $ base_dir = rtrim ( $ base_dir , DIRECTORY_SEPARATOR ) . '/' ; if ( false === isset ( static :: $ psr0 [ $ prefix ] ) ) { static :: $ psr0 [ $ prefix ] = [ ] ; } if ( true === $ prepend ) { array_uns...
Adds a base directory for a namespace prefix using the PSR - 0 standard .
48,756
public function getFirstBy ( $ key , $ value , array $ with = array ( ) ) { return $ this -> make ( $ with ) -> where ( $ key , '=' , $ value ) -> first ( ) ; }
Find an item by a key value
48,757
public function getManyBy ( $ key , $ value , array $ with = array ( ) ) { return $ this -> make ( $ with ) -> where ( $ key , '=' , $ value ) -> get ( ) ; }
Return many items by a key value
48,758
public function has ( $ relation , array $ with = array ( ) ) { $ query = $ this -> make ( $ with ) ; return $ query -> has ( $ relation ) -> get ( ) ; }
Return items that have a defined relation
48,759
public function get ( int $ timeout = 30 , $ version = HttpVersion :: HTTP_1_1 ) : HttpResponse { $ socket = $ this -> httpUri -> openSocket ( $ timeout ) ; $ this -> processHeader ( $ socket , Http :: GET , $ version ) ; return HttpResponse :: create ( $ socket ) ; }
initializes a get request
48,760
public function head ( int $ timeout = 30 , $ version = HttpVersion :: HTTP_1_1 ) : HttpResponse { $ socket = $ this -> httpUri -> openSocket ( $ timeout ) ; $ this -> headers -> put ( 'Connection' , 'close' ) ; $ this -> processHeader ( $ socket , Http :: HEAD , $ version ) ; return HttpResponse :: create ( $ socket )...
initializes a head request
48,761
public function post ( $ body , int $ timeout = 30 , $ version = HttpVersion :: HTTP_1_1 ) : HttpResponse { if ( is_array ( $ body ) ) { $ body = $ this -> transformPostValues ( $ body ) ; $ this -> headers -> put ( 'Content-Type' , 'application/x-www-form-urlencoded' ) ; } $ this -> headers -> put ( 'Content-Length' ,...
initializes a post request
48,762
private function transformPostValues ( array $ postValues ) : string { $ body = '' ; foreach ( $ postValues as $ key => $ value ) { $ body .= urlencode ( $ key ) . '=' . urlencode ( $ value ) . '&' ; } return $ body ; }
transforms post values to post body
48,763
private function processHeader ( Stream $ socket , string $ method , $ version ) { $ version = HttpVersion :: castFrom ( $ version ) ; if ( ! $ version -> equals ( HttpVersion :: HTTP_1_0 ) && ! $ version -> equals ( HttpVersion :: HTTP_1_1 ) ) { throw new \ InvalidArgumentException ( 'Invalid HTTP version ' . $ versio...
helper method to send the headers
48,764
private function methodAllowsQueryString ( string $ method ) : bool { return ( Http :: GET === $ method || Http :: HEAD === $ method ) ; }
checks if given method allows a query string
48,765
public function matchPath ( $ regexp ) { if ( substr ( $ regexp , 0 , 1 ) == '@' ) { $ this -> route_name = substr ( $ regexp , 1 ) ; } else { parent :: matchPath ( $ regexp ) ; } }
Adds a check for the route name .
48,766
private function initializeFromHardcodedObject ( $ object ) { if ( is_array ( $ object ) ) $ object = ( object ) $ object ; if ( ! empty ( $ object -> path ) ) { $ this -> path = $ object -> path ; } if ( ! empty ( $ object -> name ) ) { $ this -> name = $ object -> name ; } if ( ! empty ( $ object -> class ) ) { $ thi...
Allow programmatic initialization of a route
48,767
private function initializeFromSimpleXML ( $ xmlObject ) { $ this -> path = ! empty ( $ xmlObject -> path ) ? trim ( $ xmlObject -> path ) : '/' ; $ this -> name = ! empty ( $ xmlObject -> name ) ? trim ( $ xmlObject -> name ) : '' ; $ this -> class = ! empty ( $ xmlObject -> class ) ? trim ( $ xmlObject -> class ) : '...
Initialize from a simple XML object
48,768
private function validateRoute ( $ logReference ) { $ valid = true ; if ( empty ( $ this -> name ) ) { if ( $ logReference ) $ logReference -> error ( 'Route does not specify a name. Path(' . $ this -> path . ') Class(' . $ this -> class . ')' ) ; $ valid = false ; } if ( empty ( $ this -> path ) ) { if ( $ logReferenc...
Validates the route
48,769
public function getRoutingPath ( ) { $ tempPath = substr ( $ this -> path , 1 ) ; if ( strpos ( $ tempPath , '/' ) !== false ) { $ pathPieces = explode ( '/' , $ tempPath ) ; return $ pathPieces ; } else if ( $ tempPath ) { return array ( $ tempPath ) ; } else { return array ( ) ; } }
Returns an array of the routing path
48,770
public function validateDynamicPattern ( $ path , & $ debugInformation ) { if ( empty ( $ this -> pattern ) ) { return false ; } $ value = $ this -> pattern -> testPattern ( $ path , $ this -> parameters , $ debugInformation ) ; $ this -> validatedData = $ this -> pattern -> getValidatedData ( ) ; return $ value ; }
Validates a pattern against segments or a path
48,771
public function setRoutes ( array $ routes ) { foreach ( $ routes as $ route ) { if ( ! $ route instanceof Route ) { throw new \ InvalidArgumentException ( sprintf ( "'%s' is not a Route instance." , $ route ) ) ; } $ this -> addRoute ( $ route ) ; } }
assign routes to router
48,772
public function addRoute ( Route $ route ) { $ id = $ route -> getRouteId ( ) ; if ( array_key_exists ( $ id , $ this -> routes ) ) { throw new \ InvalidArgumentException ( sprintf ( "Route with id '%s' already exists." , $ id ) ) ; } $ this -> routes [ $ id ] = $ route ; }
add a single route to router throws an exception when route has already been assigned
48,773
public function getRouteFromPathInfo ( Request $ request ) { $ application = Application :: getInstance ( ) ; $ script = basename ( $ request -> getScriptName ( ) ) ; if ( ! ( $ path = trim ( $ request -> getPathInfo ( ) , '/' ) ) ) { $ pathSegments = [ ] ; } else { $ pathSegments = explode ( '/' , $ path ) ; } if ( co...
analyse path and return route associated with it the first path fragment can be a locale string which is then skipped for determining the route
48,774
public function getRoute ( $ routeId ) { if ( ! array_key_exists ( $ routeId , $ this -> routes ) ) { throw new ApplicationException ( sprintf ( "No route with id '%s' configured." , $ routeId ) ) ; } return $ this -> routes [ $ routeId ] ; }
get a route identified by its id
48,775
private function findRoute ( array $ pathSegments = null ) { if ( ! count ( $ this -> routes ) ) { throw new ApplicationException ( 'Routing aborted: No routes defined.' ) ; } if ( empty ( $ pathSegments ) ) { return reset ( $ this -> routes ) ; } $ pathToCheck = implode ( '/' , $ pathSegments ) ; $ requestMethod = Req...
find route which best matches the passed path segments
48,776
private function authenticateRoute ( Route $ route ) { $ auth = $ route -> getAuth ( ) ; if ( is_null ( $ auth ) ) { return true ; } if ( ! $ this -> authenticator ) { $ this -> authenticator = new DefaultRouteAuthenticator ( ) ; } return $ this -> authenticator -> authenticate ( $ route , Application :: getInstance ( ...
check whether authentication level required by route is met by currently active user
48,777
private function getSatisfiedPlaceholders ( $ route , $ path ) { $ placeholderNames = $ route -> getPlaceholderNames ( ) ; if ( ! empty ( $ placeholderNames ) ) { if ( preg_match ( '~(?:/|^)' . $ route -> getMatchExpression ( ) . '(?:/|$)~' , $ path , $ matches ) ) { array_shift ( $ matches ) ; return array_combine ( a...
check path against placeholders of route and return associative array with placeholders which would have a value assigned
48,778
public function log ( $ type , $ text , $ source = '' ) { $ log = new Logs ( ) ; $ log -> setType ( $ type ) ; $ log -> setSource ( $ source ) ; $ log -> setContent ( $ text ) ; $ this -> em -> persist ( $ log ) ; $ this -> em -> flush ( ) ; return $ log ; }
Save a log in database
48,779
final public function run ( ) { $ this -> notify ( "run" ) ; $ this -> addOptions ( ) ; $ this -> notify ( "options added" ) ; $ this -> populateOptions ( ) ; $ this -> addHelpCommand ( ) ; $ this -> notify ( "options available" ) ; if ( $ this -> option ( "help" ) ) { return $ this -> printHelp ( ) ; } $ this -> notif...
This is an instance of the template method pattern . It runs the entire Cli Command but leaves the main method abstract to ensure it is implemented in the subclass . An optional addOptions hook is also provided here .
48,780
final public function option ( $ query ) { try { $ option = $ this -> options -> find ( $ query ) ; $ value = $ option -> getValue ( ) ; } catch ( ObjectDoesNotExistException $ e ) { $ value = false ; } return $ value ; }
Returns an option s value . Facade of OptionCollection .
48,781
protected function getRawOptions ( ) { global $ argv ; if ( ! is_array ( $ this -> rawOptions ) ) { $ this -> setRawOptions ( $ argv ) ; } return $ this -> rawOptions ; }
Provides CLI arguments . Abstracted since it uses an ugly global variable . Also allows a subclass to provide its own options .
48,782
private function populateOptions ( ) { $ flatOptions = $ this -> getRawOptions ( ) ; $ this -> parser -> parseInput ( $ flatOptions ) ; $ parsed = $ this -> parser -> getOptions ( ) ; foreach ( $ parsed as $ optionName => $ optionValue ) { $ this -> options -> setValueIfExists ( $ optionName , $ optionValue ) ; } }
Gets parsed options and uses them to populate options in the options collection
48,783
final protected function printHelp ( ) { $ script = $ this -> parser -> getScriptName ( ) ; $ this -> printUsage ( $ script ) ; $ this -> printDescription ( ) ; foreach ( $ this -> options as $ option ) { echo " " . $ option . "\n" ; } echo "\n" ; $ this -> notify ( "output" ) ; $ this -> notify ( "shutdown" ) ; return...
Prints help output
48,784
public function getReflClassFromComparisonValue ( $ value ) { if ( is_array ( $ value ) ) { $ class = $ this -> namespace . '\\FindFilterComponent\\PropertyAccessArrayEquality' ; } elseif ( is_object ( $ value ) and $ value instanceof Container ) { $ class = $ this -> namespace . '\\FindFilterComponent\\PropertyAccessC...
Init the correct type of FindFilterComponent based what is passed
48,785
private function getHelper ( \ ReflectionClass $ propertyMapper , $ name , $ operation , $ value ) { $ mapper = $ propertyMapper -> newInstance ( $ name ) ; $ instance = $ this -> getReflClassFromComparisonValue ( $ value ) -> newInstance ( $ mapper , $ operation , $ value ) ; return $ instance ; }
Return a new instance of a FindFilterComponent
48,786
public function get ( $ name , $ operation , $ value ) { $ filterComponents = [ ] ; foreach ( $ this -> reflPropertyMappers as $ propertyMapper ) { $ filterComponents [ ] = $ this -> getHelper ( $ propertyMapper , $ name , $ operation , $ value ) ; } if ( 1 === count ( $ filterComponents ) ) { return $ filterComponents...
Return a new instance of a FindFilterComponent but Multi - PropertyMapperAware
48,787
protected function getRegex ( ) { if ( ! self :: $ regexDefault ) { self :: $ regexDefault = implode ( '|' , array_map ( function ( $ value ) { return "(?<=[a-z0-9]){$value}(?=[A-Z])" ; } , array_flip ( self :: $ operations ) ) ) ; self :: $ regexDefault = "/" . self :: $ regexDefault . "/" ; } return self :: $ regexDe...
Get the regular expression for identifying delimiters and tags within
48,788
private function sanitizeActions ( $ actionsString ) { $ actions = [ ] ; $ actionsString = strtolower ( $ actionsString ) ; foreach ( explode ( '|' , $ actionsString ) as $ action ) { $ action = trim ( $ action ) ; $ actions [ strstr ( $ action , ' ' , true ) ] = $ action ; } return $ actions ; }
turns actions string into array avoid duplicate actions
48,789
public function loadFile ( $ path ) { if ( ! is_string ( $ path ) ) { throw new InvalidArgumentException ( 'File must be a string' ) ; } if ( ! file_exists ( $ path ) ) { throw new InvalidArgumentException ( sprintf ( 'File "%s" does not exist' , $ path ) ) ; } $ ext = pathinfo ( $ path , PATHINFO_EXTENSION ) ; switch ...
Loads a configuration file .
48,790
private function loadIniFile ( $ path ) { $ data = parse_ini_file ( $ path , true ) ; if ( $ data === false ) { throw new UnexpectedValueException ( sprintf ( 'INI file "%s" is empty or invalid' , $ path ) ) ; } return $ data ; }
Load an INI file as an array .
48,791
private function loadPhpFile ( $ path ) { try { $ data = include $ path ; } catch ( Exception $ e ) { $ message = sprintf ( 'PHP file "%s" could not be parsed: %s' , $ path , $ e -> getMessage ( ) ) ; throw new UnexpectedValueException ( $ message , 0 , $ e ) ; } catch ( Throwable $ e ) { $ message = sprintf ( 'PHP fil...
Load a PHP file maybe as an array .
48,792
private function loadYamlFile ( $ path ) { if ( ! class_exists ( 'Symfony\Component\Yaml\Parser' ) ) { throw new LogicException ( 'YAML format requires the Symfony YAML component' ) ; } try { $ yaml = new YamlParser ( ) ; $ data = $ yaml -> parseFile ( $ path ) ; } catch ( Exception $ e ) { $ message = sprintf ( 'YAML ...
Load a YAML file as an array .
48,793
private function initLoaders ( ) { $ namespace = sprintf ( '%s\\ServiceLoader' , __NAMESPACE__ ) ; $ classes = [ 'MetadataCache' , 'MetadataDrivers' , 'MetadataFactory' , 'Persisters' , 'Rest' , 'SearchClients' ] ; foreach ( $ classes as $ class ) { $ fqcn = sprintf ( '%s\\%s' , $ namespace , $ class ) ; $ this -> addL...
Initializes all service loaders .
48,794
public function loadServices ( array $ config ) { foreach ( $ this -> loaders as $ loader ) { $ loader -> load ( $ config , $ this -> container ) ; } return $ this ; }
Loads services from all loaders .
48,795
public function toRender ( $ title , $ crud , $ data ) { $ view = $ this -> di -> get ( "view" ) ; $ pageRender = $ this -> di -> get ( "pageRender" ) ; $ view -> add ( $ crud , $ data ) ; $ tempfix = "" ; $ pageRender -> renderPage ( $ tempfix , [ "title" => $ title ] ) ; }
Sends data to view
48,796
protected function _setPathSegmentSeparator ( $ separator ) { if ( ! ( $ separator instanceof Stringable ) && ! is_string ( $ separator ) && ! is_null ( $ separator ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Invalid path segment separator' ) , null , null , $ separator ) ; } $ this -> pathS...
Assigns the separator of segments in a string path .
48,797
public function hasAccess ( UserInterface $ user , string $ permission ) : bool { return $ this -> provider -> hasRolePermission ( $ user -> getRole ( ) , $ permission ) ; }
Does the given user have access to the provided permission
48,798
public static function Read ( string $ package , string $ folder , string $ message = null , int $ code = \ E_USER_ERROR , \ Throwable $ previous = null ) : FolderAccessError { return new FolderAccessError ( $ package , $ folder , static :: ACCESS_READ , $ message , $ code , $ previous ) ; }
Init a new \ Beluga \ IO \ FolderAccessError for folder read mode .
48,799
public static function Write ( string $ package , string $ folder , string $ message = null , int $ code = \ E_USER_ERROR , \ Throwable $ previous = null ) : FolderAccessError { return new FolderAccessError ( $ package , $ folder , static :: ACCESS_WRITE , $ message , $ code , $ previous ) ; }
Init a new \ Beluga \ IO \ FolderAccessError for folder write mode .