idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
48,900 | public static function normalizePercentReal ( $ hexchr ) { $ unreserved = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . 'abcdefghijklmnopqrstuvwxyz' . '-._~' ; $ chr = chr ( hexdec ( $ hexchr [ 1 ] ) ) ; if ( strpos ( $ unreserved , $ chr ) !== false ) { return $ chr ; } return '%' . strtoupper ( $ hexchr [ 1 ] ) ; } | Performs normalization of a percent - encoded character . |
48,901 | protected function merge ( $ path ) { if ( $ this -> host !== null && $ this -> path == '' ) { return '/' . $ path ; } $ pos = strrpos ( $ this -> path , '/' ) ; if ( $ pos === false ) { return $ path ; } return substr ( $ this -> path , 0 , $ pos + 1 ) . $ path ; } | Merges the given path with the current URI s path . |
48,902 | protected function validatePath ( $ path , $ relative ) { $ pchar = '(?:' . '[-[:alnum:]\\._~!\\$&\'\\(\\)\\*\\+,;=:@]|' . '%[[:xdigit:]]' . ')' ; $ segment = '(?:' . $ pchar . '*)' ; $ segmentNz = '(?:' . $ pchar . '+)' ; $ segmentNzNc = '(?:' . '[-[:alnum:]\\._~!\\$&\'\\(\\)\\*\\+,;=@]|' . '%[[:xdigit:]]' . ')+' ; $ ... | Validates the given path . |
48,903 | protected function realSetPath ( $ path , $ relative ) { if ( ! is_string ( $ path ) || ! $ this -> validatePath ( $ path , $ relative ) ) { throw new \ InvalidArgumentException ( 'Invalid path; use relative() for relative paths' ) ; } $ this -> path = $ path ; } | Sets the current URI s path . |
48,904 | public function build ( Connection $ aConnection = null ) { Type :: addType ( 'user_email' , UserEmailType :: class ) ; Type :: addType ( 'user_id' , UserIdType :: class ) ; Type :: addType ( 'user_password' , UserPasswordType :: class ) ; Type :: addType ( 'user_roles' , UserRolesType :: class ) ; Type :: addType ( 'u... | Creates an document manager instance enabling mappings and custom types . |
48,905 | static function FindContentGroup ( Content $ content ) { $ result = null ; $ currContent = $ content ; do { $ result = $ currContent -> GetUserGroup ( ) ; $ currContent = ContentTreeUtil :: ParentOf ( $ currContent ) ; } while ( ! $ result && $ currContent ) ; if ( $ result ) { return $ result ; } return self :: GetUpp... | Finds the user group by searching in element tree |
48,906 | private static function GetUpperContentGroup ( Content $ content ) { if ( $ content -> GetPageContent ( ) ) { return self :: FindPageGroup ( $ content -> GetPageContent ( ) -> GetPage ( ) ) ; } else if ( $ content -> GetLayoutContent ( ) ) { return $ content -> GetLayoutContent ( ) -> GetArea ( ) -> GetLayout ( ) -> Ge... | Gets the upper countent user group |
48,907 | static function FindPageGroup ( Page $ page ) { $ currPage = $ page ; $ result = null ; do { $ result = $ currPage -> GetUserGroup ( ) ; $ currPage = $ currPage -> GetParent ( ) ; } while ( ! $ result && $ currPage ) ; if ( ! $ result && $ page -> GetSite ( ) ) { return $ page -> GetSite ( ) -> GetUserGroup ( ) ; } ret... | Gets the page s user group |
48,908 | protected function DESC ( $ limit = NULL ) { $ value = array_reverse ( $ this -> value ) ; if ( $ limit === NULL ) { return $ value ; } else { return array_slice ( $ value , 0 , $ limit ) ; } } | Reverse the json data |
48,909 | public function toJson ( $ all = false ) { return $ all ? json_encode ( $ this -> getAllData ( ) ) : json_encode ( $ this -> toArray ( ) ) ; } | Convert the fetched row to json |
48,910 | protected function render ( $ templates , array $ data = array ( ) ) { $ content = $ this -> view -> render ( $ templates , $ data ) ; $ response = new Response ( ) ; $ response -> setContent ( $ content ) ; return $ response ; } | Render template and get Response |
48,911 | protected function dereferenceArray ( array & $ arrayData ) { try { foreach ( $ arrayData as $ idx => $ data ) { if ( is_array ( $ data ) ) { $ this -> dereferenceArray ( $ arrayData [ $ idx ] ) ; } elseif ( false !== ( $ ref = $ this -> isReference ( $ data ) ) ) { $ arrayData [ $ idx ] = $ this -> getReferenceValue (... | Replace all the references in the array with values |
48,912 | protected function getReferenceValue ( ReferenceAbstract $ reference , $ level = 0 ) { $ name = $ reference -> getName ( ) ; if ( $ level > 2 ) { throw new NotFoundException ( Message :: get ( Message :: PARAMETER_LOOP_FOUND , $ name ) , Message :: PARAMETER_LOOP_FOUND ) ; } if ( $ reference instanceof ServiceReference... | Get the reference value |
48,913 | protected function isReference ( $ data ) { if ( is_object ( $ data ) && $ data instanceof ReferenceAbstract ) { return $ data ; } elseif ( is_string ( $ data ) ) { $ pat = '/^(@|%)([^\s]+)\1$/' ; $ mat = [ ] ; if ( preg_match ( $ pat , $ data , $ mat ) ) { return $ mat [ 1 ] === '@' ? new ServiceReference ( $ mat [ 2 ... | Is a reference string or reference object . convert to object |
48,914 | public function execute ( ) { $ this -> resultPrinter -> printBenchmarkIntro ( $ this ) ; $ results = array ( ) ; foreach ( $ this -> tests as $ test ) { $ testResults = array ( ) ; for ( $ i = 0 ; $ i < $ this -> iterations ; $ i ++ ) { $ start = time ( ) + microtime ( ) ; $ test -> run ( $ this -> parameters ) ; $ te... | Execute the registered tests and display the results |
48,915 | protected function doValidate ( ) { if ( $ this -> argumentTypes === false ) { throw new CallableFunctionValidatorException ( 'Variable $argumentTypes must be defined.' ) ; } $ argumentCount = count ( $ this -> argumentTypes ) ; $ reflectionFunction = new \ ReflectionFunction ( $ this -> callableFunction ) ; $ reflecti... | Validates callable function arguments . |
48,916 | public static function save ( $ form , $ formid , $ prepare = true ) { if ( $ prepare ) { self :: prepareSession ( ) ; } $ _SESSION [ 'bbforms' ] [ $ formid ] = $ form ; } | Save Form into session and prepare it for validation later on |
48,917 | public function load ( $ parameters , $ prepare = true ) { $ this -> parameters = $ parameters ; if ( $ prepare ) { $ this -> prepareSession ( ) ; } if ( isset ( $ parameters [ 'bootbuilder-form' ] ) && isset ( $ _SESSION [ 'bbforms' ] ) && isset ( $ _SESSION [ 'bbforms' ] [ $ parameters [ 'bootbuilder-form' ] ] ) ) { ... | Load previous form from session |
48,918 | public function validate ( ) { $ status = new ValidationResult ( ) ; if ( ! $ this -> form instanceof \ bootbuilder \ Form ) { $ status -> setError ( true ) ; return $ status ; } foreach ( $ this -> form -> getRawControls ( ) as $ nr => $ control ) { if ( ! $ this -> validateControl ( $ control , $ status ) ) { $ statu... | Validate the form controls validates by the required status and some specific control validations such as email control |
48,919 | public function create ( string $ name , callable $ definition ) { $ this -> _name = $ name ; $ this -> _definition = $ definition ; } | Create the Hook |
48,920 | public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ drv = $ params -> getDriver ( ) ; $ fieldname = $ drv -> toSQL ( $ params , $ this -> getField ( ) ) ; $ value = $ drv -> toSQL ( $ params , $ this -> getValue ( ) ) ; return $ fieldname . ' = ' . $ value ; } | Write a update assignment as SQL query syntax |
48,921 | public function toDictionary ( ) { $ value = \ ltrim ( $ this -> toNative ( ) , '?' ) ; \ parse_str ( $ value , $ data ) ; return Dictionary :: fromNative ( $ data ) ; } | Returns a Dictionary structured representation of the query string |
48,922 | public function removeSubscriber ( SubscriberInterface $ instance ) { if ( FALSE !== ( $ pos = array_search ( spl_object_hash ( $ instance ) , $ this -> registeredHashes ) ) ) { unset ( $ this -> registeredHashes [ $ pos ] ) ; foreach ( $ instance :: getEventsToSubscribe ( ) as $ eventName => $ parameters ) { $ methodN... | remove a subscriber from the registry |
48,923 | public function addSubscriber ( SubscriberInterface $ instance ) { $ this -> removeSubscriber ( $ instance ) ; $ this -> registeredHashes [ ] = spl_object_hash ( $ instance ) ; foreach ( $ instance :: getEventsToSubscribe ( ) as $ eventName => $ parameters ) { $ parameters = ( array ) $ parameters ; $ methodName = arra... | register a subscriber for event types provided by subscriber |
48,924 | public function getListeners ( $ eventName = null ) { if ( $ eventName ) { if ( empty ( $ this -> registry [ $ eventName ] ) ) { return [ ] ; } return $ this -> getSortedRegistry ( $ eventName ) ; } foreach ( $ this -> registry as $ eventName => $ listeners ) { $ this -> getSortedRegistry ( $ eventName ) ; } return $ t... | get all listeners registered for a given event name if no event name is supplied this will return all registered listeners grouped by event name and sorted by priority |
48,925 | public function hasListeners ( $ eventName = null ) { if ( $ eventName ) { return ! empty ( $ this -> registry [ $ eventName ] ) ; } foreach ( $ this -> registry as $ eventName => $ listeners ) { if ( ! empty ( $ listeners ) ) { return true ; } } return false ; } | check whether listeners for a given event name are registered if no event name is supplied this will evaluate to true if there any listeners registered |
48,926 | private function getSortedRegistry ( $ eventName ) { if ( ! isset ( $ this -> sortedRegistry [ $ eventName ] ) ) { $ this -> sortedRegistry [ $ eventName ] = [ ] ; if ( isset ( $ this -> registry [ $ eventName ] ) ) { krsort ( $ this -> registry [ $ eventName ] ) ; $ this -> sortedRegistry [ $ eventName ] = call_user_f... | helper method to collect all listener callbacks for a named event into one array observing priorities |
48,927 | public function noReferer ( ) { if ( $ this -> getParameter ( 'url' ) == null ) return ; if ( $ this -> getParameter ( 'service' ) == null ) return "http://hiderefer.com/?" . $ this -> getParameter ( 'url' ) ; return $ this -> getParameter ( 'service' ) . $ this -> getParameter ( 'url' ) ; } | Returns a url safe from referers |
48,928 | public function appendQueryString ( ) { $ url = $ this -> getParameter ( 'url' ) ; $ params = $ this -> getParameters ( ) ; unset ( $ params [ 'url' ] ) ; return URLUtils :: appendQueryString ( $ url , $ params ) ; } | Constructs a URL with query string arguments from the given base url and parameters |
48,929 | public static function getTitleById ( $ table , $ id ) { if ( $ table == "users" ) { return self :: getUserForIndexListing ( $ id ) ; } if ( $ table == "posts" ) { return self :: getPostForIndexListing ( $ id ) ; } $ title = DB :: table ( $ table ) -> where ( 'id' , '=' , $ id ) -> pluck ( 'title' ) ; if ( $ title == "... | Grab the title by ID |
48,930 | public static function getPostForIndexListing ( $ id ) { $ title = DB :: table ( 'posts' ) -> where ( 'id' , '=' , $ id ) -> pluck ( 'title' ) ; $ html = $ title . " (" . $ id . ")" ; return $ html ; } | Grab the Post info from the posts table . Created specifically for the Post Updates index listing |
48,931 | public static function finagleVarcharFieldTypeForIndexListing ( $ field , $ data ) { if ( empty ( $ field [ 'persist_wash' ] ) ) { return $ data ; } if ( strtolower ( $ field [ 'persist_wash' ] ) == "url" ) { $ prefacedURL = self :: prefaceURLwithHTTP ( $ data ) ; return '<a href="' . $ prefacedURL . '" target="_blank"... | Need a helper method to finagle the varchar field in the index listing . |
48,932 | public static function categoryParentSingleSelectCreate ( $ categories ) { $ html = "" ; $ html .= '<select name="parent_id" id="parent_id" size="6" class="form-control" >' ; $ html .= '<option ' ; $ html .= 'value="' ; $ html .= 0 ; $ html .= '">' ; $ html .= 'No Parent Category' ; $ html .= '</option>"' ; foreach ( $... | Create a dropdown with a single select for the parent category |
48,933 | public static function categoryParentSingleSelectEdit ( $ categories , $ parent_id , $ category_id ) { $ html = "" ; $ html .= '<select name="parent_id" id="parent_id" size="6" class="form-control">' ; $ html .= '<option ' ; if ( $ parent_id == 0 ) { $ html .= ' selected="selected" ' ; } $ html .= 'value="' ; $ html .=... | Create a multiple select drop down for tags that have the existing tags for that post already selected |
48,934 | public static function adminPageTitle ( $ package_title , $ table_type_plural , $ extra_title = '' ) { $ table_type_plural = self :: properPlural ( $ table_type_plural ) ; $ html = '' ; $ html .= '<br /><br />' ; $ html .= '<div class="row">' ; $ html .= ' <div class="oaerror info">' ; $ html .= ' <strong>' .... | Page title for admin pages |
48,935 | public static function adminPageSubTitle ( $ record = null , $ modelClass , $ show = false ) { $ modelClass = self :: properPlural ( $ modelClass ) ; $ html = '' ; $ html .= '<div class="row">' ; $ html .= '<div class="col-md-3"></div>' ; $ html .= '<div class="col-md-6">' ; $ html .= '<h1>' ; $ html .= '<span class="l... | Display button with a label describing what the form is doing . |
48,936 | public static function adminFormFieldLabel ( $ field ) { $ name = $ field [ 'name' ] ; if ( ! empty ( $ field [ 'alternate_form_name' ] ) ) { $ name = $ field [ 'alternate_form_name' ] ; } if ( $ name == "id" ) return "ID" ; $ html = str_replace ( "_" , " " , $ name ) ; $ html = ucwords ( $ html ) ; return $ html ; } | Transform the field name into a format suitable for a form label |
48,937 | public static function properPlural ( $ pluralWordToCheck ) { $ listOfPlurals = [ 'categorys' => 'categories' , 'kb_item' => 'item' , 'kb_items' => 'Items' , 'list_email' => 'email list' , 'listlist' => 'list' , 'people' => 'person' , 'peoples' => 'people' , 'postupdate' => 'post update' , 'postupdates' => 'post update... | Is the plural word grammatically correct? |
48,938 | public static function determineEpisodeImagePath ( $ episode , $ show ) { if ( empty ( $ episode -> featured_image ) ) { return $ show -> featured_image ; } return $ show -> image_file_storage_url . $ episode -> featured_image ; } | What is the episode s image s path? |
48,939 | public static function createOpenGraphTagsForPost ( $ post ) { return [ 'og:title' => $ post -> title , 'og:type' => 'article' , 'og:url' => $ post -> canonical_url , 'og:image' => $ post -> urlImage , 'og:description' => $ post -> meta_description , 'og:site_name' => Config :: get ( 'lasallecmsfrontend.og_site_name' )... | Create an array of OG tags and their values for a post . |
48,940 | public static function createTwitterTagsForPost ( $ post ) { return [ 'twitter:card' => Config :: get ( 'lasallecmsfrontend.twitter_card' ) , 'twitter:site' => Config :: get ( 'lasallecmsfrontend.twitter_site' ) , 'twitter:title' => $ post -> title , 'twitter:description' => $ post -> meta_description , 'twitter:creato... | Create an array of Twitter tags and their values for a post . |
48,941 | public static function prefaceURLwithHTTP ( $ url ) { $ url = trim ( $ url ) ; if ( substr ( $ url , 0 , 7 ) == "http://" ) { return $ url ; } if ( substr ( $ url , 0 , 8 ) == "https://" ) { return $ url ; } return "http://" . $ url ; } | Make sure the URL is fully qualified |
48,942 | public function processClassMetadata ( ClassMetadata $ metadata , $ property , $ prefix ) { if ( in_array ( $ metadata -> getName ( ) , $ this -> processedClasses ) ) { return ; } $ metadata -> mapEmbedded ( [ 'fieldName' => $ property , 'class' => $ this -> embeddableMetadata -> getName ( ) , 'columnPrefix' => empty (... | Processes the class metadata . |
48,943 | protected function normalizeObject ( $ object , $ format , array $ context ) { if ( ! $ this -> serializer instanceof NormalizerInterface ) { throw new LogicException ( 'Cannot normalize object because the injected serializer is not a normalizer' ) ; } return $ this -> serializer -> normalize ( $ object , $ format , $ ... | Normalizes the object . |
48,944 | protected function denormalizeObject ( $ data , $ class , $ format , array $ context ) { if ( ! $ this -> serializer instanceof DenormalizerInterface ) { throw new LogicException ( 'Cannot denormalize object because the injected serializer is not a denormalizer' ) ; } return $ this -> serializer -> denormalize ( $ data... | Denormalizes the object . |
48,945 | public static function rotateX ( array & $ array , int $ distance , int $ startX = 0 , int $ startY = 0 , int $ stopX = null , int $ stopY = null ) { self :: prepare ( $ array , $ stopX , $ stopY ) ; $ rotateLeft = $ distance > 0 ; $ distance = abs ( $ distance ) % ( $ stopX - $ startX ) ; $ x = $ rotateLeft ? $ startX... | Array items rotate left if distance is greater than 0 . |
48,946 | public static function rotateY ( array & $ array , int $ distance , int $ startX = 0 , int $ startY = 0 , int $ stopX = null , int $ stopY = null ) { self :: prepare ( $ array , $ stopX , $ stopY ) ; $ rotateUp = $ distance > 0 ; $ distance = abs ( $ distance ) % ( $ stopY - $ startY ) ; $ y = $ rotateUp ? $ startY + $... | Array items rotate up if distance is greater than 0 . |
48,947 | public function statisticsEnd ( $ name ) { $ this -> hr ( ) ; $ this -> out ( 'Took: ' . $ this -> _startTime [ $ name ] -> diff ( new DateTime ( ) ) -> format ( '%ad %hh %im %ss' ) ) ; $ this -> out ( 'Memory: ' . sprintf ( '%0.3f' , memory_get_peak_usage ( true ) / ( 1024 * 1024 ) ) . "Mb max used" ) ; $ this -> hr (... | Stop and output statistics |
48,948 | public function sqlDump ( $ sorted = false , $ clear = true ) { if ( ! class_exists ( 'ConnectionManager' ) || Configure :: read ( 'debug' ) < 2 ) { return ; } $ sources = ConnectionManager :: sourceList ( ) ; $ logs = array ( ) ; foreach ( $ sources as $ source ) { $ db = ConnectionManager :: getDataSource ( $ source ... | Shows sql dump |
48,949 | public function query ( $ query ) { if ( method_exists ( $ this -> db , 'query' ) ) { return $ this -> db -> query ( $ query ) ; } else { throw new Exception ( __METHOD__ . " not implemented" ) ; } } | The following methods either execute or if the method is not defined throw an Exception |
48,950 | public function allowAttribute ( $ attribute ) { if ( is_array ( $ attribute ) ) { foreach ( $ attribute as $ attrib ) $ this -> allowed_attributes [ $ attrib ] = true ; } else $ this -> allowed_attributes [ $ attribute ] = true ; return $ this ; } | Add an attribute to the whitelist |
48,951 | public function removeTag ( $ tag ) { if ( is_array ( $ tag ) ) { foreach ( $ tag as $ t ) { if ( isset ( $ this -> allowed_tags [ $ t ] ) ) unset ( $ this -> allowed_tags [ $ t ] ) ; $ this -> remove_tags [ $ t ] = true ; } } else { if ( isset ( $ this -> allowed_tags [ $ tag ] ) ) unset ( $ this -> allowed_tags [ $ t... | Add a tag to the list of tags to remove including all child nodes |
48,952 | public function allowProtocol ( $ protocol ) { if ( is_array ( $ protocol ) ) { foreach ( $ protocol as $ proto ) $ this -> allowed_protocols [ $ proto ] = true ; } else $ this -> allowed_protocols [ $ protocol ] = true ; return $ this ; } | Add a protocol to the list of protocols to allow linking to . |
48,953 | public function getHTML ( ) { $ dom = new DOMDocument ( ) ; $ interceptor = new ErrorInterceptor ( array ( $ dom , 'loadHTML' ) ) ; $ interceptor -> registerError ( E_WARNING , "DOMDocument::loadHTML" ) ; $ interceptor -> execute ( $ this -> html ) ; $ body = $ dom -> getElementsByTagName ( 'body' ) -> item ( 0 ) ; $ t... | Return the sanitized HTML according to the set up list of tags and attributes . |
48,954 | private function sanitizeNode ( DOMNode $ node ) { $ child = ( ! empty ( $ node -> childNodes ) && $ node -> childNodes -> length > 0 ) ? $ node -> childNodes -> item ( 0 ) : null ; while ( $ child !== null ) { $ tag = $ child -> nodeName ; if ( $ tag === "#text" ) { $ child = $ child -> nextSibling ; continue ; } if (... | Helper function to recursively sanitize nodes |
48,955 | private function unwrapContents ( DOMNode $ node , DOMNode $ child ) { $ next = $ child -> nextSibling ; if ( $ next === null ) $ next = $ child ; if ( $ child -> childNodes !== null ) { $ l = $ child -> childNodes -> length ; for ( $ i = $ l - 1 ; $ i >= 0 ; -- $ i ) { $ sub = $ child -> childNodes [ $ i ] ; $ next = ... | Helper function to unwrap the contents of a node and remove the node . |
48,956 | private function sanitizeAttributes ( DOMNode $ child ) { $ remove_attributes = array ( ) ; foreach ( $ child -> attributes as $ attrib ) { $ name = $ attrib -> name ; if ( ! isset ( $ this -> allowed_attributes [ $ name ] ) ) { $ remove_attributes [ ] = $ attrib ; } elseif ( $ name === "href" ) { $ val = $ attrib -> n... | Helper function to sanitize the attributes for the specified node . |
48,957 | protected static function _recursiveJsonExprFinder ( & $ value , array & $ javascriptExpressions , $ currentKey = null ) { if ( $ value instanceof Expr ) { $ magicKey = " _" . $ currentKey . "_" . ( count ( $ javascriptExpressions ) ) ; $ javascriptExpressions [ ] = array ( "magicKey" => ( is_int ( $ currentKey ) ) ? $... | Check & Replace Aegis \ JSON \ Expr for tmp ids in the valueToEncode |
48,958 | public static function prettyPrint ( $ json , $ options = array ( ) ) { $ tokens = preg_split ( '|([\{\}\]\[,])|' , $ json , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ result = "" ; $ indent = 0 ; $ ind = " " ; if ( isset ( $ options [ 'indent' ] ) ) { $ ind = $ options [ 'indent' ] ; } $ inLiteral = false ; foreach ( $ t... | Pretty - print JSON string |
48,959 | public static function getInstance ( $ connect = true ) { if ( ! isset ( self :: $ instances [ static :: class ] ) ) { self :: $ instances [ static :: class ] = new static ( ) ; } $ instance = self :: $ instances [ static :: class ] ; if ( $ connect ) { $ instance -> connect ( ) ; } return $ instance ; } | Gets the singleton instance of the DB . Used throughout the framework . |
48,960 | public static function groupArray ( $ arr , $ groupField ) { $ result = array ( ) ; foreach ( $ arr as $ data ) { $ id = $ data [ $ groupField ] ; if ( isset ( $ result [ $ id ] ) ) { $ result [ $ id ] [ ] = $ data ; } else { $ result [ $ id ] = array ( $ data ) ; } } return $ result ; } | Groupping elements by field |
48,961 | public static function recursiveArraySearch ( $ needleKey , $ needleValue , array $ haystack ) { foreach ( $ haystack as $ key => $ value ) { $ currentKey = $ key ; if ( ( $ currentKey == $ needleKey && ( $ needleValue === null || $ needleValue == $ value ) ) || ( is_array ( $ value ) && self :: recursiveArraySearch ( ... | Search in array |
48,962 | protected function updatePaymentState ( PaymentInterface $ payment , $ nextState ) { if ( $ payment -> getState ( ) !== $ nextState ) { $ stateMachine = $ this -> factory -> get ( $ payment ) ; if ( null !== $ transition = $ stateMachine -> getTransitionToState ( $ nextState ) ) { $ stateMachine -> apply ( $ transition... | Updates the payment state . |
48,963 | protected function pImplode ( array $ nodes , $ glue = '' ) { $ strings = $ this -> pIterator ( $ nodes ) ; return implode ( $ glue , $ strings ) ; } | Pretty prints an array of nodes and implodes the printed values . |
48,964 | protected function pCommaSeparated ( array $ nodes , $ max_len = 80 ) { $ result = '' ; $ line = '' ; $ strings = $ this -> pIterator ( $ nodes ) ; foreach ( $ strings as $ node_str ) { if ( $ line !== '' && strlen ( $ line ) + strlen ( $ node_str ) > $ max_len ) { $ result .= $ line . ",\n" ; $ line = ' ' . $ node_... | Pretty prints an array of nodes and implodes the printed values with commas . |
48,965 | public function scanInstall ( ) { if ( ! $ this -> lockSystemChanges ) { foreach ( $ this -> ApplicationContext -> detectPluginDirectories ( ) -> getPluginDirectories ( ) as $ pluginDir ) { if ( is_dir ( $ pluginDir ) ) { $ slug = basename ( $ pluginDir ) ; if ( ! $ this -> PluginService -> slugExists ( $ slug ) ) { $ ... | Scans the plugin directories and installs plugins as needed |
48,966 | public function processPluginXML ( Plugin $ plugin , Errors & $ errors , & $ log = '' , $ xml = false ) { if ( ! $ xml ) $ xml = $ this -> loadXML ( $ plugin -> Path ) ; $ this -> processConfig ( $ plugin , $ log , $ xml ) ; $ this -> processPermissions ( $ plugin , $ log , $ xml ) ; $ this -> processCMSNavItems ( $ pl... | Processes the plugin s plugin . xml file |
48,967 | public function processPermissions ( Plugin $ plugin , & $ log = '' , $ xml = false ) { if ( ! $ xml ) $ xml = $ this -> loadXML ( $ plugin -> Path ) ; if ( ! $ xml ) throw new Exception ( 'Missing plugin.xml file for plugin [' . $ plugin -> Slug . ']' ) ; $ perms = $ xml -> permissions ; if ( ! empty ( $ perms ) ) for... | Add all of the Plugin s permissions from the specified XML |
48,968 | public function processConfig ( Plugin $ plugin , & $ log = '' , $ xml = false ) { if ( ! $ xml ) $ xml = $ this -> loadXML ( $ plugin -> Path ) ; if ( ! $ xml ) throw new Exception ( 'Missing plugin.xml file for plugin [' . $ plugin -> Slug . ']' ) ; if ( ! empty ( $ xml -> config ) ) { $ snippet = trim ( strval ( $ x... | Appends the plugin s config snippet to the config file |
48,969 | public function processCMSNavItems ( Plugin $ plugin , & $ log = '' , $ xml = false ) { if ( ! $ xml ) $ xml = $ this -> loadXML ( $ plugin -> Path ) ; if ( ! $ xml ) throw new Exception ( 'Missing plugin.xml file for plugin [' . $ plugin -> Slug . ']' ) ; $ processedSlugs = array ( ) ; $ navitems = $ xml -> cmsnavitem... | Add all the CMS nav items from the plugin |
48,970 | protected function insertCMSNavItem ( CMSNavItem $ cms_nav_item , Plugin $ plugin ) { $ cms_nav_item -> PluginID = $ plugin -> PluginID ; $ cms_nav_item -> ModifiedDate = $ plugin -> ModifiedDate ; try { if ( ! $ this -> CMSNavItemService -> slugExists ( $ cms_nav_item -> Slug ) ) { $ this -> CMSNavItemService -> add (... | Inserts the specified CMS Nav Item |
48,971 | protected function processElements ( Plugin $ plugin , & $ log = '' , $ xml = false ) { if ( ! $ xml ) $ xml = $ this -> loadXML ( $ plugin -> Path ) ; if ( ! $ xml ) throw new Exception ( 'Missing plugin.xml file for plugin [' . $ plugin -> Slug . ']' ) ; $ processedSlugs = array ( ) ; $ elements = $ xml -> elements ;... | Add all the elements defined by this plugin |
48,972 | public function processInstallScript ( Plugin $ plugin , & $ log ) { $ script = $ plugin -> Path . '/install.php' ; if ( file_exists ( $ script ) ) { include_once $ script ; } } | Runs the install script from the plugin |
48,973 | public function processUpgradeScript ( Plugin $ plugin , & $ log , $ installedVersion ) { $ script = $ plugin -> Path . '/upgrade.php' ; if ( file_exists ( $ script ) ) include_once $ script ; } | Runs the upgrade script for the plugin |
48,974 | public function autoupgradePlugin ( Plugin $ plugin ) { if ( empty ( $ plugin ) || ! $ plugin -> isInstalled ( ) || ! $ plugin -> isEnabled ( ) ) return ; $ xml = $ this -> loadXML ( $ plugin -> Path ) ; if ( empty ( $ xml ) ) return ; if ( $ plugin -> Version != ( $ newversion = strval ( $ xml -> info -> version ) ) )... | Reruns the aspect installation to upgrade the plugin if needed |
48,975 | public function upgradePlugin ( $ pluginSlug , $ pluginPath , Errors & $ errors ) { $ log = "" ; $ plugin = $ this -> PluginService -> getBySlug ( $ pluginSlug ) ; $ existingPriority = $ plugin -> Priority ; if ( empty ( $ plugin ) || ! $ plugin -> isInstalled ( ) ) { $ log .= "Plugin is not installed." ; return array ... | Force an upgrade of the specified plugin |
48,976 | public function uninstallPlugin ( $ pluginSlug , Errors $ errors , $ purge = false ) { $ log = "" ; $ plugin = $ this -> PluginService -> getBySlug ( $ pluginSlug ) ; if ( empty ( $ plugin ) || ! $ plugin -> isInstalled ( ) ) { $ log .= "Plugin not installed." ; return array ( $ log , 'fail' ) ; } $ pluginPath = $ plug... | Removes the specified plugin |
48,977 | protected function uninstallAspects ( Plugin $ plugin ) { $ dto = new DTO ( array ( 'PluginID' => $ plugin -> PluginID ) ) ; $ aspects = $ this -> AspectService -> findAll ( $ dto ) -> getResults ( ) ; foreach ( $ aspects as $ aspect ) { $ this -> AspectService -> delete ( $ aspect -> Slug ) ; } } | Removes all aspects that were installed by this plugin |
48,978 | protected function uninstallCMSNavItems ( Plugin $ plugin ) { $ dto = new DTO ( array ( 'PluginID' => $ plugin -> PluginID ) ) ; $ navitems = $ this -> CMSNavItemService -> findAll ( $ dto ) -> getResults ( ) ; rsort ( $ navitems ) ; foreach ( $ navitems as $ navitem ) { $ this -> CMSNavItemService -> delete ( $ navite... | Removes all cms nav items that were installed by this plugin |
48,979 | private function attachListeners ( HasEmitterInterface $ object , array $ listeners ) { $ emitter = $ object -> getEmitter ( ) ; foreach ( $ listeners as $ el ) { if ( $ el [ 'once' ] ) { $ emitter -> once ( $ el [ 'name' ] , $ el [ 'fn' ] , $ el [ 'priority' ] ) ; } else { $ emitter -> on ( $ el [ 'name' ] , $ el [ 'f... | Attaches event listeners and properly sets their priorities and whether or not they are are only executed once . |
48,980 | private function buildListener ( $ name , $ data , & $ listeners ) { static $ defaults = [ 'priority' => 0 , 'once' => false ] ; if ( is_callable ( $ data ) ) { $ data = [ 'fn' => $ data ] ; } if ( isset ( $ data [ 'fn' ] ) ) { $ data [ 'name' ] = $ name ; $ listeners [ ] = $ data + $ defaults ; } elseif ( is_array ( $... | Creates a complete event listener definition from the provided array of listener data . Also works recursively if more than one listeners are contained in the provided array . |
48,981 | public function validTimeStr ( $ time ) { if ( $ time === '0000-00-00 00:00:00' ) { return true ; } if ( $ this -> fitNonExistingDates && $ this -> isNonExistingTimeString ( $ time ) ) { $ time = $ this -> getPossibleDateString ( $ time ) ; } return ( is_string ( $ time ) && strlen ( $ time ) == 19 && $ time == date ( ... | validate an string ... only valid datestring will pass |
48,982 | public function setData ( $ data ) { if ( is_array ( $ data ) ) { $ this -> data = $ data ; } $ args = func_get_args ( ) ; $ this -> data [ $ args [ 0 ] ] = $ args [ 1 ] ; return $ this ; } | Sets form data |
48,983 | public function setHolders ( $ holders ) { if ( is_array ( $ holders ) ) { $ this -> holders = $ holders ; } $ args = func_get_args ( ) ; $ this -> holders [ $ args [ 0 ] ] = $ args [ 1 ] ; return $ this ; } | Sets place holders |
48,984 | public function show ( array $ fields ) { $ this -> show = array ( ) ; foreach ( $ fields as $ field ) { $ this -> show [ $ field ] = true ; } return $ this ; } | Shows only the specified in the order specified |
48,985 | public function register ( $ alias , \ Closure $ closure ) { if ( ! is_string ( $ alias ) ) throw new Exception ( 'Application::register() requires a string as the first parameter.' ) ; $ this -> registered [ $ alias ] = $ closure ; return true ; } | Registers a alias and Closure pair in the IoC container . |
48,986 | public function get ( $ alias ) { if ( ! isset ( $ this -> registered [ $ alias ] ) ) return false ; if ( isset ( $ this -> instance [ $ alias ] ) && is_object ( $ this -> instance [ $ alias ] ) ) return $ this -> instance [ $ alias ] ; $ this -> instance [ $ alias ] = $ this -> registered [ $ alias ] ( $ this ) ; if (... | Returns the instance associated with the supplied alias . |
48,987 | public function getNew ( $ alias ) { if ( ! isset ( $ this -> registered [ $ alias ] ) ) return false ; $ object = $ this -> registered [ $ alias ] ( $ this ) ; if ( ! is_object ( $ object ) ) throw new Exception ( 'The alias "' . $ alias . '" does not return an object.' ) ; return $ object ; } | Returns a new instance associated with the supplies alias . |
48,988 | public function validateUserPassword ( $ attributes , $ params ) { $ this -> _user = Users :: model ( ) -> findByPk ( Yii :: app ( ) -> user -> id ) ; if ( $ this -> _user == NULL ) { $ this -> addError ( 'password' , Yii :: t ( 'HybridAuth.main' , 'Unable to identify user.' ) ) ; return false ; } $ hash = Users :: mod... | Ensures that the password entered matches the one provided during registration |
48,989 | public function save ( ) { if ( ! $ this -> validate ( ) ) return false ; $ meta = new UserMetadata ; $ meta -> attributes = array ( 'user_id' => $ this -> _user -> id , 'key' => $ this -> provider . 'Provider' , 'value' => $ this -> adapter -> identifier ) ; return $ meta -> save ( ) ; } | Bind s the user identity to the mdoel |
48,990 | public function hydrate ( $ puppetModules , $ revision ) { if ( $ revision -> hasGroups ( ) ) { foreach ( $ revision -> getGroups ( ) as $ group ) { $ this -> groupHydrator -> hydrate ( $ puppetModules , $ group ) ; } } } | Hydrate revision with the provided puppet modules data . |
48,991 | protected function loadBuffer ( ) { $ this -> buffer = '' ; if ( $ this -> finished ) { return ; } while ( ! $ this -> stream -> eof ( ) && strlen ( $ this -> buffer ) < $ this -> chunkSize ) { $ this -> buffer .= $ this -> stream -> read ( $ this -> chunkSize - strlen ( $ this -> buffer ) ) ; } if ( $ this -> buffer =... | Read data from the underlying input stream into the read buffer . |
48,992 | final public function getMessage ( $ parsed = true ) { return ( $ parsed ) ? $ this -> parseMessages ( $ this -> messages ) : $ this -> messages ; } | Fetches the flash message |
48,993 | final public function getSuccessMessage ( $ parsed = true ) { return ( $ parsed ) ? $ this -> parseMessages ( $ this -> successMessages ) : $ this -> successMessages ; } | Fetches the flash success message |
48,994 | final public function getErrorMessage ( $ parsed = true ) { return ( $ parsed ) ? $ this -> parseMessages ( $ this -> errorMessages ) : $ this -> errorMessages ; } | Fetches the flash error message |
48,995 | public function process ( Request $ request , Result $ result ) { $ this -> setRequest ( $ request ) ; $ this -> setResult ( $ result ) ; $ this -> respond ( ) ; } | Implement the Processor interface . |
48,996 | public function setResponseCode ( int $ code ) { if ( $ code < 100 || $ code > 599 ) { $ err = new \ InvalidArgumentException ( "Attempting to set status code to $code" ) ; self :: $ logger -> critical ( "Invalid status {0}: {1}" , [ $ code , $ err ] ) ; $ this -> response_code = 500 ; } else { $ this -> response_code ... | Set the HTTP Response code |
48,997 | public function endAllOutputBuffers ( $ lvl = 0 ) { $ ob_cnt = 0 ; while ( ob_get_level ( ) > $ lvl ) { ++ $ ob_cnt ; $ contents = ob_get_contents ( ) ; ob_end_clean ( ) ; if ( self :: $ logger instanceof \ Psr \ Log \ NullLogger ) continue ; $ lines = explode ( "\n" , $ contents ) ; foreach ( $ lines as $ n => $ line ... | Close all active output buffers and log their contents |
48,998 | public function respond ( ) { if ( null === $ this -> result ) { $ this -> result = new Result ; $ this -> result -> setResponse ( new Error ( 500 , "No output produced" ) ) ; } $ this -> endAllOutputBuffers ( $ this -> target_ob_level ) ; $ response = $ this -> result -> getResponse ( ) ; $ mime = $ response -> getMim... | Prepare the output before sending it run hooks collect headers and finally call doRespond which produces the output . |
48,999 | protected function doOutput ( string $ mime ) { http_response_code ( $ this -> response_code ) ; if ( ! headers_sent ( ) ) { foreach ( $ this -> headers as $ name => $ value ) header ( $ name . ': ' . $ value ) ; foreach ( $ this -> cookies as $ cookie ) { setcookie ( $ cookie -> getName ( ) , $ cookie -> getValue ( ) ... | This method sends data to the client after all preparational work has been done . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.