idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
229,700
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
229,701
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
229,702
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
229,703
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
229,704
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
229,705
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
229,706
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
229,707
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
229,708
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
229,709
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 .
229,710
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 .
229,711
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 .
229,712
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
229,713
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
229,714
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
229,715
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
229,716
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
229,717
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
229,718
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
229,719
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 .
229,720
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 .
229,721
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 .
229,722
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 .
229,723
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 .
229,724
public function loadServices ( array $ config ) { foreach ( $ this -> loaders as $ loader ) { $ loader -> load ( $ config , $ this -> container ) ; } return $ this ; }
Loads services from all loaders .
229,725
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
229,726
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 .
229,727
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
229,728
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 .
229,729
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 .
229,730
private function getSaveToBody ( RequestInterface $ request , StreamInterface $ stream ) { if ( $ saveTo = $ request -> getConfig ( ) [ 'save_to' ] ) { $ saveTo = is_string ( $ saveTo ) ? new Stream ( Utils :: open ( $ saveTo , 'r+' ) ) : Stream :: factory ( $ saveTo ) ; } else { $ saveTo = Stream :: factory ( ) ; } Ut...
Drain the stream into the destination stream
229,731
private function createStream ( RequestInterface $ request , & $ http_response_header ) { static $ methods ; if ( ! $ methods ) { $ methods = array_flip ( get_class_methods ( __CLASS__ ) ) ; } $ params = [ ] ; $ options = $ this -> getDefaultOptions ( $ request ) ; foreach ( $ request -> getConfig ( ) -> toArray ( ) as...
Create the stream for the request with the context options .
229,732
public function openDir ( ) { if ( ! $ this -> isDir ( ) ) { throw new IOException ( "Not a directory" ) ; } $ dirconv = DirectoryConverter :: fromPath ( $ this ) ; $ dirconv -> setRoot ( $ this -> getRootDirectory ( ) ) ; $ type = $ this -> getDirectoryType ( ) ; return new $ type ( $ dirconv ) ; }
Open new Directory instance
229,733
public function get ( $ request , $ match , $ p ) { $ backend = parent :: getObject ( $ request , $ match , $ p ) ; if ( $ backend -> tenant !== Tenant_Shortcuts_GetMainTenant ( ) -> id ) { throw new Pluf_HTTP_Error404 ( "Object not found (" . $ p [ 'model' ] . "," . $ backend -> id . ")" ) ; } return $ backend ; }
Returns bank - backend determined by given id . This method returns backend if and only if backend with given id blongs to main tenant else it throws not found exception
229,734
public function set ( string $ key , $ value ) : Option { $ option = $ this -> repository -> find ( $ key ) ; return $ option -> setValue ( $ value ) ; }
Set the value for a specific key .
229,735
protected function containerName ( $ container = null ) { if ( $ container !== null ) { return $ container ; } $ pos = strrpos ( $ this -> entity , '\\' ) ; if ( $ pos === false ) { return $ this -> entity ; } return substr ( $ this -> entity , strrpos ( $ this -> entity , '\\' ) + 1 ) ; }
Returns container name or builds it from namespaced class name if passed name is empty string
229,736
protected function assignKeys ( array $ keys , array & $ container ) { foreach ( $ keys as $ local => $ foreign ) { $ this -> assertField ( $ local ) ; $ this -> assertField ( $ foreign ) ; $ container [ $ local ] = $ foreign ; } }
Assigns key pairs to passed container
229,737
protected function assertTroughKeys ( $ inKeys , $ outKeys ) { if ( empty ( $ inKeys ) || empty ( $ outKeys ) ) { throw new DefinitionException ( sprintf ( 'Invalid keys for relation "%s", must be two arrays with key-value pairs' , $ this -> entity , count ( $ inKeys ) ) ) ; } if ( count ( $ inKeys ) !== count ( $ outK...
Asserts trough keys must be same number in both arrays
229,738
protected function assertField ( $ field ) { if ( empty ( $ field ) ) { throw new DefinitionException ( sprintf ( 'Invalid field name for relation "%s.%s" can not be empty' , $ this -> entity , $ field ) ) ; } if ( is_numeric ( $ field ) ) { throw new DefinitionException ( sprintf ( 'Invalid field name for relation "%s...
Asserts field name
229,739
public function disableSubmit ( array & $ form , FormStateInterface $ form_state ) { $ types = array ( ) ; foreach ( $ form_state -> getValue ( 'types' ) as $ type => $ selected ) { if ( $ type === $ selected ) { $ types [ ] = $ type ; } } if ( empty ( $ types ) ) { drupal_set_message ( $ this -> t ( "Nothing to do" ) ...
Notification types admin form disable selected submit handler
229,740
public function find ( $ key , $ disableLateLoading = null ) { if ( ! is_bool ( $ disableLateLoading ) ) { $ disableLateLoading = false ; } if ( is_null ( $ key ) or ! is_scalar ( $ key ) or strlen ( trim ( $ key ) ) === 0 ) { return null ; } $ class = $ this -> entityClass ; try { return $ this -> entityFactory ( $ ke...
Lookup a entity based on it s primary key or key column This will either return null or a Entity
229,741
private function entityFactory ( ) { $ entity = $ this -> reflEntityClass -> newInstanceWithoutConstructor ( ) ; if ( $ this -> reflEntityManagerPropertyOfEntity ) { $ this -> reflEntityManagerPropertyOfEntity -> setValue ( $ entity , $ this -> entityManager ) ; } call_user_func_array ( [ $ entity , '__construct' ] , f...
Temp helper method which actually does the instantiation work and ensure our Entity has a link to the EntityManager
229,742
public function make ( array $ data = null ) { if ( ! $ this -> makeableSafetyCheck ( ) ) { return null ; } $ entity = $ this -> entityFactory ( ) ; if ( $ data !== null ) { $ entity -> set ( $ data , null , $ entity -> inputValidate ) ; } return $ entity ; }
Returns a new entity of the correct type .
229,743
protected function makeableSafetyCheck ( ) { switch ( $ this -> makeable ) { case self :: MAKEABLE_DISABLE : return false ; case self :: MAKEABLE_EXCEPTION : throw new EntityNotMakeableException ( "Making objects of this type is restricted. Are you using a view or some other derived data." ) ; } return true ; }
Check to see if a repository is makeable
229,744
public function hasReference ( $ reference , & $ referenceDetail = null ) { $ referenceDetail = null ; foreach ( $ this -> __get ( 'references' ) as $ name => $ detail ) { if ( $ name == $ reference or $ detail [ 0 ] == $ reference ) { $ referenceDetail = $ detail ; return $ name ; } } return null ; }
Check if Entity has link
229,745
public function referencesGet ( $ entityOrContainer , $ reference , $ source = null ) { if ( ! ( $ entityOrContainer instanceof Base || $ entityOrContainer instanceof Container ) ) { throw new \ InvalidArgumentException ( "You can only lookup references by Entity or Container" ) ; } if ( ! $ this -> hasReference ( $ re...
Get all references
229,746
public function hasLink ( $ link , & $ linkDetail = null ) { $ links = $ this -> __get ( 'links' ) ; if ( isset ( $ links [ $ link ] ) ) { $ linkDetail = $ links [ $ link ] ; return $ link ; } foreach ( $ links as $ via => $ linkDetail ) { if ( in_array ( $ link , $ linkDetail -> foreignEntities ) ) { return $ via ; } ...
Check if Entity has a named link
229,747
public function findByApiKey ( $ value ) { $ apiOptions = $ this -> __get ( 'apiOptions' ) ; if ( ! isset ( $ apiOptions [ 'findByKey' ] ) ) { return $ this -> find ( $ value , true ) ; } $ property = $ apiOptions [ 'findByKey' ] ; $ filter = $ this -> getFindFilterFactory ( ) -> get ( $ property , null , $ value ) ; r...
Look up a entity based on it s api key
229,748
private function getFindFilterFactory ( $ source = 0 ) { $ propertyMappers = [ PropertyMapperEntityData :: class ] ; if ( $ source & Base :: INITIAL ) { $ propertyMappers [ ] = [ PropertyMapperEntityInitial :: class ] ; } return new FindFilterComponentFactory ( $ propertyMappers ) ; }
Instantiate a appropriate FindFilterFactory
229,749
protected function findByFilterComponentsSourceSetup ( $ source ) { if ( ! ( $ source & ( self :: PERSISTED | self :: UNPERSISTED ) ) ) { $ source += self :: PERSISTED + self :: UNPERSISTED ; } if ( ! ( $ source & ( self :: CHANGED | self :: UNCHANGED ) ) ) { $ source += self :: CHANGED + self :: UNCHANGED ; } if ( ! (...
Set source defaults . Helper method of findByFilterComponents
229,750
public function findByFilterComponentsFormatReturnValue ( $ qty , Container $ output ) { if ( $ qty === FindFilterComponentFactory :: FIND_ALL ) { return $ output ; } switch ( $ count = count ( $ output ) ) { case 0 : return null ; case 1 : return $ output -> pop ( ) ; } throw new IncompatibleQtyException ( "{$count} e...
Format the return value of a findByFilterComponents query
229,751
protected function findByFilterComponentsDatabase ( array $ filterComponents , $ source ) { $ query = $ this -> buildQuery ( $ this -> db , $ filterComponents ) ; $ result = $ this -> db -> query ( $ query ) -> fetch ( Result :: FLATTEN_PREVENT ) ; $ isChangedFilterCallback = $ this -> getFilterByIsChangedCallback ( $ ...
Find a entity having been passed the filters .
229,752
protected function buildQuery ( QuoteInterface $ db , $ filterComponents ) { $ filterTags = array ( ) ; $ dataTypes = $ this -> dataTypesGet ( ) ; if ( $ dataTypesMissing = array_diff ( array_keys ( $ filterComponents ) , array_keys ( $ dataTypes ) ) ) { throw new \ LogicException ( sprintf ( "The following keys `%s` d...
Build a Query object
229,753
public function dataTypesGet ( $ filter = null ) { if ( func_num_args ( ) > 1 and \ Bond \ array_check ( 'is_string' , func_get_args ( ) ) ) { $ filter = func_get_args ( ) ; } if ( is_int ( $ filter ) ) { $ dataTypes = array ( ) ; if ( $ filter & DataType :: PRIMARY_KEYS ) { $ dataTypes += array_filter ( $ this -> data...
Helper function . Get dataTypes for this Entity .
229,754
public function getFilterByIsChangedCallback ( $ source ) { $ changed = ! ( $ source & self :: CHANGED ) ; $ unchanged = ! ( $ source & self :: UNCHANGED ) ; if ( $ changed and $ unchanged ) { return function ( ) { return false ; } ; } if ( ! $ changed and ! $ unchanged ) { return function ( ) { return true ; } ; } ret...
Filter entities by their changed status .
229,755
protected function makeNewContainer ( ) { $ container = new Container ( ) ; $ container -> classSet ( $ this -> entityClass ) ; $ container -> setPropertyMapper ( PropertyMapperEntityData :: class ) ; return $ container ; }
Get a new Container
229,756
public function actionCreate ( ) { $ model = new Role ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'view' , 'id' => $ model -> name ] ) ; } else { return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; } }
Creates a new Role model . If creation is successful the browser will be redirected to the view page .
229,757
protected function findModel ( $ id ) { if ( ( $ model = Role :: findByName ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( Yii :: t ( 'maddoger/user' , 'The requested role does not exist.' ) ) ; } }
Finds the Role model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
229,758
public function flush ( $ tag ) { $ args = func_get_args ( ) ; foreach ( $ args as $ item ) { if ( in_array ( $ item , $ this -> sequence ) ) { $ this -> $ item = [ ] ; } } return $ this ; }
MAKE LIKE SELECT TO EMPTY ARRAY!
229,759
public function getBindings ( ) { $ keys = func_num_args ( ) < 1 ? array_keys ( $ this -> bindings ) : func_get_args ( ) ; $ args = [ ] ; foreach ( $ keys as $ item ) { if ( ! array_key_exists ( $ item , $ this -> bindings ) ) { continue ; } $ args = array_merge ( $ args , $ this -> bindings [ $ item ] ) ; } return $ a...
Get the current query value bindings in a flattened array .
229,760
public function setLogo ( $ logo = null ) { if ( is_array ( $ logo ) ) { $ logo = null ; } $ this -> logo = $ logo ; return $ this ; }
Set logo .
229,761
public function compose ( Section $ section = null ) : Result { $ this -> container -> set ( 'section' , $ section ) ; if ( null !== $ section ) { $ this -> initParams ( ) ; $ this -> setParams ( $ section -> params ) ; $ this -> container -> set ( 'params' , $ this -> params ) ; } $ this -> setData ( $ section ) ; ret...
Main controller method compose all content .
229,762
protected function initParams ( ) : void { if ( 0 != count ( $ this -> params ) ) { return ; } $ this -> addParams ( [ Parameter :: makeBool ( 'isRoot' , '' , 'none' , false , true ) , Parameter :: makeBool ( 'isRss' , 'rss' , 'path' , false , false ) , Parameter :: makeInt ( 'itemId' , '' , 'path' , false , 0 ) , Para...
Initialization of structures of module parameters with default values .
229,763
protected function setDataFromModel ( ModelInterface $ model ) : void { $ this -> container -> set ( 'model' , $ model ) ; foreach ( get_class_methods ( $ model ) as $ method ) { if ( 0 !== strpos ( $ method , 'get' ) ) { continue ; } $ this -> data [ strtolower ( substr ( $ method , 3 ) ) ] = $ model -> $ method ( ) ;...
This implementation calls all methods with prefix get from model . Implementation may be overridden in inherited method to call only necessary model methods dependently from parameters .
229,764
public function composeWidgets ( array $ widgetsData ) : array { $ container = clone $ this -> container ; unset ( $ container -> widget ) ; unset ( $ container -> widgets ) ; unset ( $ container -> model ) ; $ widgetsResults = [ ] ; foreach ( $ widgetsData as $ place => $ placeWidgets ) { $ results = [ ] ; foreach ( $...
Create object for each widgets data item .
229,765
protected function setProperty ( $ name , $ value ) { $ this -> properties [ str_replace ( ' ' , '' , ltrim ( ucwords ( preg_replace ( '/[^A-Z^a-z^0-9]+/' , ' ' , 'z' . $ name ) ) , 'Z' ) ) ] = $ value ; $ this -> properties [ str_replace ( ' ' , '' , ucwords ( preg_replace ( '/[^A-Z^a-z^0-9]+/' , ' ' , $ name ) ) ) ] ...
Sets a property on this container .
229,766
public function getPages ( $ cursor = false ) { $ queryArray = [ 'pageSize' => 200 ] ; if ( $ cursor ) { $ queryArray [ 'cursor' ] = $ cursor ; } try { $ response = $ this -> client -> get ( $ this -> PagesUrl , [ 'headers' => [ 'Authorization' => 'Bearer ' . $ this -> login -> apiKey ] , 'verify' => $ this -> certFile...
Base function get call get users pages
229,767
public function getAllUserPages ( $ returnResponse = array ( ) , $ cursor = false ) { if ( empty ( $ this -> login -> apiKey ) ) { $ this -> login -> getApiKey ( ) ; } $ response = $ this -> getPages ( $ cursor ) ; $ response = json_decode ( $ response [ 'response' ] , true ) ; if ( empty ( $ returnResponse ) && empty ...
Recursive function to get all of a users pages
229,768
public function stripB3NonPublished ( $ pages ) { foreach ( $ pages [ '_items' ] as $ index => $ page ) { if ( $ page [ 'isBuilderThreePage' ] && ! $ page [ 'isBuilderThreePublished' ] ) { unset ( $ pages [ '_items' ] [ $ index ] ) ; } } return $ pages ; }
Remove non published B3 pages
229,769
public function sortPages ( $ pages ) { usort ( $ pages [ '_items' ] , function ( $ a , $ b ) { return strcmp ( strtolower ( $ a [ "name" ] ) , strtolower ( $ b [ "name" ] ) ) ; } ) ; return $ pages ; }
sort pages in alphabetical user
229,770
public function getSinglePageDownloadUrl ( $ pageId ) { try { $ response = $ this -> client -> get ( $ this -> PagesUrl . '/' . $ pageId , [ 'headers' => [ 'Authorization' => 'Bearer ' . $ this -> login -> apiKey ] , 'verify' => $ this -> certFile , ] ) ; $ body = json_decode ( $ response -> getBody ( ) , true ) ; $ ur...
Get the url to download the page url from
229,771
public function downloadPageHtml ( $ pageId , $ isRetry = false ) { if ( is_null ( $ this -> login -> apiKey ) ) { $ this -> login -> apiKey = $ this -> login -> getApiKey ( ) ; } $ response = $ this -> getSinglePageDownloadUrl ( $ pageId ) ; if ( $ response [ 'error' ] ) { return $ response ; } $ responseArray = json_...
get url for page then use a get request to get the html for the page
229,772
public function connection ( $ name = 'default' ) { if ( ! isset ( $ this ) ) return self :: getInstance ( ) -> clients [ Config :: get ( "redis.$name" ) ] ; return $ this -> clients [ Config :: get ( "redis.$name" ) ] ; }
Get a specific Redis connection instance .
229,773
public function write ( $ output ) { $ resource = fopen ( 'php://temp' , 'r+' ) ; ! $ resource && $ resource = null ; $ stream = new Stream ( $ resource ) ; $ stream -> write ( ( string ) $ output ) ; $ this -> stream = $ stream ; return $ this ; }
Writes data directly to the stream .
229,774
public function simpleRendeArray ( ) { $ array = [ ] ; $ count = $ this -> paginator -> getCount ( ) ; $ url = $ this -> path ; $ current = $ this -> paginator -> getCurrentPage ( ) ; $ appends = $ this -> createAppendString ( $ this -> paginator -> getAppends ( ) ) ; $ fragments = $ this -> createFragmentsString ( $ t...
create pagination with only previous and next buttons
229,775
private function createBeforeButton ( $ current , $ url , $ class , $ fragments ) { if ( $ this -> isAvaibleCurrentPage ( $ current ) && $ current > 1 ) { $ page = $ current - 1 ; return $ this -> buildChieldString ( "&laquo;" , $ url , $ class , $ fragments , $ page ) ; } else { return false ; } }
build before button string
229,776
private function createAfterButton ( $ current , $ limit , $ url , $ class , $ fragments ) { if ( $ this -> isAvaibleCurrentPage ( $ current ) && $ current < $ limit ) { $ page = $ current - 1 ; return $ this -> buildChieldString ( "&laquo;" , $ url , $ class , $ fragments , $ page ) ; } else { return false ; } }
&raquo ; build next button string
229,777
private function buildChieldString ( $ page , $ url , $ pageName , $ fragments , $ i ) { settype ( $ page , 'string' ) ; $ add = $ this -> buildAddUrl ( $ url ) ; $ string = $ url . $ add . $ i . $ fragments ; return sprintf ( "<li><a href='%s' class='%s'>%s</a></li>" , $ string , $ pageName , $ page ) ; }
create chield string
229,778
protected function fetchSubTemplateName ( ) { if ( ! empty ( $ this -> subTemplate ) ) return ; $ className = get_called_class ( ) ; if ( mb_strpos ( $ className , 'Controllers' ) === false ) { $ this -> system -> log ( ) -> notice ( "Fully qualified Controller class name does not contain 'Controllers' so we can't auto...
Fetch sub template name
229,779
public function connection ( $ config = null , $ forceConnect = false ) { if ( $ this -> connection && ! $ forceConnect ) { return $ this -> connection ; } ! isset ( $ config ) || $ this -> config ( $ config ) ; $ ref = new \ ReflectionClass ( $ this -> getHandler ( ) ) ; try { $ this -> connection = $ ref -> newInstan...
Returns a PDO connection
229,780
public function closeTag ( $ compiler , $ expectedTag ) { if ( count ( $ compiler -> _tag_stack ) > 0 ) { list ( $ _openTag , $ _data ) = array_pop ( $ compiler -> _tag_stack ) ; if ( in_array ( $ _openTag , ( array ) $ expectedTag ) ) { if ( is_null ( $ _data ) ) { return $ _openTag ; } else { return $ _data ; } } $ c...
Pop closing tag
229,781
public function acquire ( $ expires ) { if ( $ expires <= 0 ) { return true ; } $ k = $ this -> getName ( ) ; $ this -> lock = $ this -> factory -> createLock ( $ k , $ expires ) ; return $ this -> lock -> acquire ( ) ; }
Attempts to acquire the global lock for this job .
229,782
public function splitFile ( $ dstDir , $ chunkSize = 2048 ) { $ dstDir = rtrim ( $ dstDir , DIRECTORY_SEPARATOR ) ; $ srcFile = fopen ( $ this -> filePath , 'r' ) ; $ totalSize = filesize ( $ this -> filePath ) ; $ chunksNo = ceil ( $ totalSize / $ chunkSize ) ; $ lastChunkSize = $ totalSize % $ chunkSize ; if ( $ last...
Split file into chunks and save it to destination .
229,783
public static function v4 ( ) { return bin2hex ( Yii :: $ app -> security -> generateRandomKey ( 4 ) ) . "-" . bin2hex ( Yii :: $ app -> security -> generateRandomKey ( 2 ) ) . "-" . dechex ( mt_rand ( 0 , 0x0fff ) | 0x4000 ) . "-" . dechex ( mt_rand ( 0 , 0x3fff ) | 0x8000 ) . "-" . bin2hex ( Yii :: $ app -> security ...
Creates an v4 UUID
229,784
public static function fromParts ( string $ scheme , string $ host , int $ port = null , string $ path = '/' , string $ queryString = null ) : self { return self :: fromString ( $ scheme . '://' . $ host . ( null === $ port ? '' : ':' . $ port ) . $ path . ( ( null !== $ queryString ) ? ( substr ( $ queryString , 0 , 1...
creates http uri from given uri parts
229,785
public static function castFrom ( $ value , string $ name = 'Uri' ) : self { if ( $ value instanceof self ) { return $ value ; } if ( is_string ( $ value ) ) { return self :: fromString ( $ value ) ; } throw new \ InvalidArgumentException ( $ name . ' must be a string containing a HTTP URI or an instance of ' . get_cla...
casts given value to an instance of HttpUri
229,786
private function isValidForRfc ( string $ rfc ) : bool { if ( $ this -> parsedUri -> hasUser ( ) && Http :: RFC_7230 === $ rfc ) { throw new MalformedUri ( 'The URI ' . $ this -> parsedUri -> asString ( ) . ' is not a valid HTTP URI according to ' . Http :: RFC_7230 . ': contains userinfo, but this is disallowed' ) ; }...
checks if uri is valid according to given rfc
229,787
public static function exists ( $ httpUri , callable $ checkWith = null ) : bool { if ( $ httpUri instanceof self ) { return $ httpUri -> hasDnsRecord ( $ checkWith ) ; } if ( empty ( $ httpUri ) || ! is_string ( $ httpUri ) ) { return false ; } try { return self :: fromString ( $ httpUri ) -> hasDnsRecord ( $ checkWit...
checks whether given http uri exists i . e . has a DNS entry
229,788
public static function isValid ( $ httpUri ) : bool { if ( $ httpUri instanceof self ) { return true ; } if ( empty ( $ httpUri ) || ! is_string ( $ httpUri ) ) { return false ; } try { self :: fromString ( $ httpUri ) ; } catch ( MalformedUri $ murle ) { return false ; } return true ; }
checks whether given http uri is syntactically valid
229,789
protected function isSyntacticallyValid ( ) : bool { if ( ! parent :: isSyntacticallyValid ( ) ) { return false ; } if ( ! $ this -> parsedUri -> schemeEquals ( Http :: SCHEME ) && ! $ this -> parsedUri -> schemeEquals ( Http :: SCHEME_SSL ) ) { return false ; } return true ; }
Checks whether URI is a correct URI .
229,790
public function hasDnsRecord ( callable $ checkWith = null ) : bool { $ checkdnsrr = null === $ checkWith ? 'checkdnsrr' : $ checkWith ; if ( $ this -> parsedUri -> isLocalHost ( ) || $ checkdnsrr ( $ this -> parsedUri -> hostname ( ) , 'A' ) || $ checkdnsrr ( $ this -> parsedUri -> hostname ( ) , 'AAAA' ) || $ checkdn...
checks whether host of uri is listed in dns
229,791
public function hasDefaultPort ( ) : bool { if ( ! $ this -> parsedUri -> hasPort ( ) ) { return true ; } if ( $ this -> isHttp ( ) && $ this -> parsedUri -> portEquals ( Http :: PORT ) ) { return true ; } if ( $ this -> isHttps ( ) && $ this -> parsedUri -> portEquals ( Http :: PORT_SSL ) ) { return true ; } return fa...
checks whether the uri uses a default port or not
229,792
public function toHttp ( int $ port = null ) : self { if ( $ this -> isHttp ( ) ) { if ( null !== $ port && ! $ this -> parsedUri -> portEquals ( $ port ) ) { return new ConstructedHttpUri ( $ this -> parsedUri -> transpose ( [ 'port' => $ port ] ) ) ; } return $ this ; } $ changes = [ 'scheme' => Http :: SCHEME ] ; if...
transposes uri to http
229,793
public function toHttps ( int $ port = null ) : self { if ( $ this -> isHttps ( ) ) { if ( null !== $ port && ! $ this -> parsedUri -> portEquals ( $ port ) ) { return new ConstructedHttpUri ( $ this -> parsedUri -> transpose ( [ 'port' => $ port ] ) ) ; } return $ this ; } $ changes = [ 'scheme' => Http :: SCHEME_SSL ...
transposes uri to https
229,794
public function createSocket ( ) : Socket { return new Socket ( $ this -> hostname ( ) , $ this -> port ( ) , ( ( $ this -> isHttps ( ) ) ? ( 'ssl://' ) : ( null ) ) ) ; }
creates a socket to this uri
229,795
public function openSocket ( int $ timeout = 5 , callable $ openWith = null ) : Stream { $ socket = $ this -> createSocket ( ) ; if ( null !== $ openWith ) { $ socket -> openWith ( $ openWith ) ; } return $ socket -> connect ( ) -> setTimeout ( $ timeout ) ; }
opens socket to this uri
229,796
private function register ( $ socialUser ) { $ names = explode ( ' ' , $ socialUser -> getName ( ) ) ; $ username = is_null ( $ socialUser -> getNickname ( ) ) ? $ socialUser -> getEmail ( ) : $ socialUser -> getNickname ( ) ; $ userDetails = [ 'username' => $ username , 'email' => $ socialUser -> getEmail ( ) , 'first...
Create a new user from a social user .
229,797
public function eof ( ) { if ( ! $ this -> hasRead ) { $ this -> mark ( ) ; $ ret = fgetc ( $ this -> handle ) ; if ( $ ret === false ) return true ; $ this -> reset ( ) ; } return feof ( $ this -> handle ) ; }
Returns true if the end of the stream has been reached .
229,798
public function TopMost ( ) { $ sql = Access :: SqlBuilder ( ) ; $ tblParams = PageUrlParameter :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tblParams -> Field ( 'PageUrl' ) , $ sql -> Value ( $ this -> pageUrl -> GetID ( ) ) ) -> And_ ( $ sql -> IsNull ( $ tblParams -> Field ( 'Previous' ) ) ) ; return P...
Gets the first page url parameter
229,799
public static function init ( array $ attributes = array ( ) ) { self :: $ table_attributes = array ( ) ; self :: $ rows = array ( ) ; self :: $ row_data = array ( ) ; self :: $ headers = array ( ) ; self :: $ footers = array ( ) ; self :: setAttributes ( $ attributes ) ; }
Sets up a new table