idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
54,900 | protected function _rtl ( ) { $ this -> _chars ( ) -> rewind ( ) ; while ( $ this -> _chars ( ) -> valid ) { if ( $ this -> _chars ( ) -> current ( ) -> ltr ) return false ; $ this -> _chars ( ) -> next ; } return true ; } | Checks whether the whole string is right to left . |
54,901 | protected function _ltr ( ) { $ this -> _chars ( ) -> rewind ( ) ; while ( $ this -> _chars ( ) -> valid ) { if ( $ this -> _chars ( ) -> current ( ) -> rtl ) return false ; $ this -> _chars ( ) -> next ; } return true ; } | Checks whether the whole string is written from the left to the right . |
54,902 | public function tag ( $ tag_expr ) { self :: mustBeString ( $ tag_expr , 'Tag expression' ) ; $ arr = array ( ) ; $ tags = preg_split ( '/\s+/ui' , $ tag_expr ) ; $ detectId = function ( $ str , & $ tag ) { if ( preg_match ( '/#/ui' , $ str ) ) { $ id = preg_split ( '/#/ui' , $ str ) ; $ out = array_shift ( $ id ) ; if... | Embeds current string into one or more tags . |
54,903 | public function untag ( $ tag = null ) { if ( ! is_null ( $ tag ) ) { $ allowed = '' ; $ tagify = function ( $ tag ) { $ output = function ( $ str ) { $ str = preg_replace ( '@[</>]+@' , '' , $ str ) ; return '<' . $ str . '>' ; } ; if ( $ tag instanceof \ DOMNode ) { return $ output ( $ tag -> nodeName ) ; } elseif ( ... | Removes HTML and XML tags . |
54,904 | private function _nl ( $ type , $ after = true ) { if ( $ after ) { return new self ( $ this -> value . $ type ) ; } else { return new self ( $ type . $ this -> value ) ; } } | Add new CR LF CRLF or PHP_EOL before or after the string . |
54,905 | public function transform ( SplFileInfo $ file ) { try { $ taxonomyFile = $ this -> fileToTaxonomyFile -> transform ( $ file ) ; $ taxonomy = $ this -> buildTaxonomy ( $ taxonomyFile ) ; return $ taxonomy ; } catch ( \ Exception $ e ) { throw new TransformationFailure ( $ e -> getMessage ( ) , 0 , $ e , $ file -> getRe... | Transforms a file into a Taxonomy |
54,906 | public static function exceptionHandler ( \ Exception $ e ) { $ error = Error :: createFromException ( $ e , Response :: STATUS_ERROR ) ; $ status = method_exists ( $ e , 'getStatus' ) ? $ e -> getStatus ( ) : Response :: STATUS_ERROR ; Container :: get ( 'response' ) -> setStatus ( $ status ) ; Container :: get ( 'con... | Internal exception handler |
54,907 | public static function shutdownHandler ( $ type = E_ERROR ) { $ error = error_get_last ( ) ; if ( $ error [ "type" ] & $ type ) { self :: errorHandler ( $ error [ "type" ] , $ error [ "message" ] , $ error [ "file" ] , $ error [ "line" ] ) ; } } | Internal shutdown handler |
54,908 | public static function getRawData ( $ data_str ) { if ( is_string ( $ data_str ) && ( $ data_str == "''" || $ data_str == '""' ) ) { $ data = '' ; } else { $ data = $ data_str ; } if ( ! empty ( $ data ) && ( $ data { 0 } == '{' || $ data { 0 } == '[' ) ) { try { $ data = self :: json_decode ( $ data ) ; } catch ( \ Ex... | Get a final data transformed if it was JSON encoded |
54,909 | public function getApplication ( ) { if ( ! is_null ( $ this -> session ) ) { return $ this -> session -> getApplication ( ) ; } else { return $ this -> context -> getSystem ( ) -> getApplication ( ) ; } } | Shortcut to Application object either provided by Session or by Context |
54,910 | public function getUser ( ) { if ( ! is_null ( $ this -> session ) ) { return $ this -> session -> getUser ( ) ; } else { return $ this -> context -> getSystem ( ) -> getUser ( ) ; } } | Shortcut to User object either provided by Session or by Context |
54,911 | public function getIntent ( ) { if ( $ this -> getRequest ( ) -> getType ( ) != 'IntentRequest' ) { throw new InvalidArgumentException ( 'This request is not an IntentRequest.' ) ; } $ request = $ this -> getRequest ( ) ; return $ request -> getIntent ( ) ; } | Shortcut to Intent object |
54,912 | private function _tableExists ( ) { try { $ result = mysqli_query ( $ this -> link , "SELECT 1 FROM $this->table_name LIMIT 1" ) ; } catch ( \ Exception $ e ) { return FALSE ; } return $ result !== FALSE ; } | Check if a table exists in the current database . |
54,913 | protected function _t_loader_namespacestack_getMatchedFromStack ( $ name , $ recursivelyNamespaceStack = null ) { $ matched = array ( ) ; if ( empty ( $ recursivelyNamespaceStack ) && $ recursivelyNamespaceStack !== null ) return $ matched ; if ( $ this -> _t_loader_namespacestack_cache_SortNamespaces !== $ this -> _t_... | Binary search for matching with requested resource namespace |
54,914 | protected function _t_loader_namespacestack_watchAndResolve ( $ name , $ match , $ resolveWatch ) { ( $ resolveWatch !== null ) ? : $ resolveWatch = function ( $ resource ) { return ( $ resource ) ? $ resource : false ; } ; $ this -> _t_loader_namespacestack_fixResourceList ( $ match ) ; $ return = false ; foreach ( $ ... | - usually watch closure implemented by extended classes it s just simple resolver filter |
54,915 | public function configureByConfigString ( $ configString ) { $ successsfullyConfigured = false ; if ( true === is_string ( $ configString ) && '' !== $ configString && 3 === mb_substr_count ( $ configString , self :: FEATURE_CONFIGSTRING_SECTION_DELIMITER ) ) { list ( $ percentageString , $ usersString , $ rolesString ... | Configure the feature with a single string |
54,916 | public function clearConfig ( ) { $ this -> setPercentage ( ( integer ) 0 ) ; $ this -> setUsers ( array ( ) ) ; $ this -> setRoles ( array ( ) ) ; $ this -> setGroups ( array ( ) ) ; return $ this ; } | Resets the feature config |
54,917 | public function isActive ( RolloutAbstract $ rollout , DeterminableUserInterface $ user = null ) { if ( 100 === $ this -> getPercentage ( ) ) { return true ; } if ( ! $ user instanceof DeterminableUserInterface ) { return false ; } $ userId = $ user -> getId ( ) ; if ( true === $ this -> isUserInPercentage ( $ userId )... | Check if this feature is active for the given userId |
54,918 | public function addUser ( $ userId ) { if ( true === is_numeric ( $ userId ) && false === in_array ( $ userId , $ this -> users ) ) { $ this -> users [ ] = ( int ) $ userId ; } return $ this ; } | Adds a user to the list of user IDs that should be explicitly enabled for this feature |
54,919 | public function removeUser ( $ userId ) { if ( true === is_numeric ( $ userId ) && true === in_array ( $ userId , $ this -> users ) ) { foreach ( array_keys ( $ this -> users , ( int ) $ userId , true ) as $ key ) { unset ( $ this -> users [ $ key ] ) ; } } return $ this ; } | Removes a user from the list of user IDs that should be explicitly enabled for this feature |
54,920 | public function addRole ( $ roleName ) { if ( true === is_string ( $ roleName ) && false === in_array ( $ roleName , $ this -> roles ) ) { $ this -> roles [ ] = $ roleName ; } return $ this ; } | Adds a role to the list of role names that should be enabled for this feature |
54,921 | public function removeRole ( $ roleName ) { if ( true === is_string ( $ roleName ) && true === in_array ( $ roleName , $ this -> roles ) ) { foreach ( array_keys ( $ this -> roles , ( string ) $ roleName , true ) as $ key ) { unset ( $ this -> roles [ $ key ] ) ; } } return $ this ; } | Removes a role from the list of role names that should be enabled for this feature |
54,922 | public function addGroup ( $ groupName ) { if ( true === is_string ( $ groupName ) && false === in_array ( $ groupName , $ this -> groups ) ) { $ this -> groups [ ] = $ groupName ; } return $ this ; } | Adds a group to the list of group names that should be enabled for this feature |
54,923 | public function removeGroup ( $ groupName ) { if ( true === is_string ( $ groupName ) && true === in_array ( $ groupName , $ this -> groups ) ) { foreach ( array_keys ( $ this -> groups , ( string ) $ groupName , true ) as $ key ) { unset ( $ this -> groups [ $ key ] ) ; } } return $ this ; } | Removes a group from the list of group names that should be enabled for this feature |
54,924 | protected function checkUserIds ( array $ userIds ) { $ checkedUserIds = array ( ) ; foreach ( $ userIds as $ userId ) { if ( true === is_numeric ( $ userId ) && false === in_array ( $ userId , $ checkedUserIds ) ) { $ checkedUserIds [ ] = ( int ) $ userId ; } } return $ checkedUserIds ; } | Checks the user IDs and returns only the valid ones |
54,925 | protected function checkRoles ( array $ roles ) { $ checkedRoles = array ( ) ; foreach ( $ roles as $ role ) { if ( true === is_string ( $ role ) && false === in_array ( $ role , $ checkedRoles ) ) { $ checkedRoles [ ] = ( string ) $ role ; } } return $ checkedRoles ; } | Checks the roles and returns only the valid ones |
54,926 | protected function checkGroups ( array $ groups ) { $ checkedGroups = array ( ) ; foreach ( $ groups as $ group ) { if ( true === is_string ( $ group ) && false === in_array ( $ group , $ checkedGroups ) ) { $ checkedGroups [ ] = ( string ) $ group ; } } return $ checkedGroups ; } | Checks the groups and returns only the valid ones |
54,927 | public function writeLogMessage ( IncrementalOutputReceivedEvent $ event ) { $ project = $ event -> getProject ( ) ; $ process = $ event -> getProcess ( ) ; $ incrementalOutput = $ event -> getIncrementalOutput ( ) ; $ command = $ process -> getCommandLine ( ) ; $ filename = sprintf ( '%s%s.project.log' , $ this -> log... | Writes the incremental output received into a log file . |
54,928 | public function getUrl ( $ languageCode = null ) { if ( $ languageCode && in_array ( $ languageCode , Language :: getAllowedLanguages ( ) ) ) { return $ this -> url . '&lang=' . $ languageCode ; } return $ this -> url ; } | Get the url of the Invoice |
54,929 | public function getController ( ) { if ( $ controllerData = $ this -> component -> getData ( '_controller' ) ) { return $ controllerData ; } return $ this -> variation -> getConfiguration ( 'components' , $ this -> component -> getComponentType ( ) -> getName ( ) , 'controller' , $ this -> component -> getComponentType... | Returns context component controller . |
54,930 | public function getTemplatePath ( ) { if ( $ templateData = $ this -> component -> getData ( '_template' ) ) { return $ templateData ; } return $ this -> variation -> getConfiguration ( 'components' , $ this -> component -> getComponentType ( ) -> getName ( ) , 'path' , $ this -> component -> getComponentType ( ) -> ge... | Returns context component template path . |
54,931 | public function match ( $ mixed ) { if ( ! ( $ mixed instanceof Request ) && ! is_string ( $ mixed ) ) { throw new \ InvalidArgumentException ( sprintf ( "Invalid Argument Error: Invalid type param, it can be a url string or a Request object, '%s' given." , gettype ( $ mixed ) ) ) ; } if ( $ this -> sortRoutesEnabled )... | Match a url string given as parameter or with Request info . |
54,932 | protected function sortRoutes ( ) { $ routes = array ( ) ; foreach ( $ this -> routes as $ i => $ item ) { $ this -> routes [ $ i ] [ 'patCount' ] = count ( explode ( '/' , $ item -> getPattern ( ) ) ) ; $ this -> routes [ $ i ] [ 'reqCount' ] = count ( $ item -> getRequirements ( ) ) ; $ this -> routes [ $ i ] [ 'varC... | This method sorts all routes connected to the mapper |
54,933 | protected function isCached ( $ filename ) { if ( ! empty ( $ this -> cacheDir ) ) { return false ; } $ cacheFile = $ this -> cacheDir . DIRECTORY_SEPARATOR . $ filename . ".cache" ; if ( file_exists ( $ cacheFile ) && is_array ( $ this -> cacheContent = include ( $ cacheFile ) ) && $ this -> cacheContent [ "_chk" ] ==... | Verify is a file is cached |
54,934 | protected function saveInCache ( $ filename , $ content ) { if ( empty ( $ this -> cacheDir ) || ! is_dir ( $ this -> cacheDir ) || ! is_writable ( $ this -> cacheDir ) ) { return false ; } $ content [ "_chk" ] = filemtime ( $ filename ) ; file_put_contents ( $ this -> cacheDir . DIRECTORY_SEPARATOR . basename ( $ file... | Save in cache |
54,935 | protected function configureMachine ( array $ config ) { $ this -> loadMachineConfig ( $ config , [ 'table' , 'table_alias' , 'state_select' , 'filters' ] ) ; if ( $ this -> properties === null ) { if ( empty ( $ config [ 'properties' ] ) ) { $ this -> scanTableColumns ( ) ; } } parent :: configureMachine ( $ config ) ... | Define state machine used by all instances of this type . |
54,936 | protected function scanTableColumns ( ) { $ driver = $ this -> flupdo -> getAttribute ( \ PDO :: ATTR_DRIVER_NAME ) ; switch ( $ driver ) { case 'sqlite' : $ r = $ this -> flupdo -> query ( 'PRAGMA table_info(' . $ this -> flupdo -> quoteIdent ( $ this -> table ) . ')' ) ; $ this -> properties = array ( ) ; foreach ( $... | Scan table in database and populate properties . |
54,937 | protected function checkAccessPolicy ( $ access_policy_name , Reference $ ref ) { if ( empty ( $ access_policy_name ) ) { return true ; } if ( ! isset ( $ this -> access_policies [ $ access_policy_name ] ) ) { throw new \ InvalidArgumentException ( 'Unknown policy: ' . $ access_policy_name ) ; } $ access_policy = $ thi... | Returns true if user has required access_policy . |
54,938 | protected function queryAddAccessPolicyCondition ( $ access_policy_name , $ query ) { if ( empty ( $ access_policy_name ) ) { return ; } if ( ! isset ( $ this -> access_policies [ $ access_policy_name ] ) ) { throw new \ InvalidArgumentException ( 'Unknown policy: ' . $ access_policy_name ) ; } $ access_policy = $ this... | Adds conditions to enforce read access_policy to query object . |
54,939 | public function createListing ( $ filters , $ filtering_flags = 0 ) { $ q = $ this -> createQueryBuilder ( ) ; $ this -> queryAddStateSelect ( $ q ) ; $ this -> queryAddPropertiesSelect ( $ q ) ; if ( isset ( $ this -> listing_access_policy ) ) { $ this -> queryAddAccessPolicyCondition ( $ this -> listing_access_policy... | Create generic listing on this machine type . |
54,940 | public function createQueryBuilder ( ) { $ q = $ this -> flupdo -> select ( ) ; $ this -> queryAddFrom ( $ q ) ; $ this -> queryAddAccessPolicyCondition ( $ this -> read_access_policy , $ q ) ; return $ q ; } | Create query builder . |
54,941 | protected function queryGetThisTable ( $ query ) { if ( $ this -> table_alias ) { return $ query -> quoteIdent ( $ this -> table ) . ' AS ' . $ query -> quoteIdent ( $ this -> table_alias ) ; } else { return $ query -> quoteIdent ( $ this -> table ) ; } } | Get table name with alias |
54,942 | private function queryAddPropertySelect ( \ Smalldb \ Flupdo \ FlupdoBuilder $ query , string $ table_alias , string $ property_name , array $ property , string $ property_prefix = '' ) { $ table_q = $ query -> quoteIdent ( $ table_alias ) ; $ p_q = $ query -> quoteIdent ( $ property_name ) ; $ pa_q = $ query -> quoteI... | Add a single property to the query . |
54,943 | protected function queryAddPrimaryKeyWhere ( $ query , $ id , $ clause = 'where' ) { $ table = $ query -> quoteIdent ( $ this -> table_alias ? $ this -> table_alias : $ this -> table ) ; if ( $ id === null || $ id === array ( ) || $ id === false || $ id === '' ) { throw new InvalidArgumentException ( 'Empty ID.' ) ; } ... | Add primary key condition to where clause . Result should contain only one row now . |
54,944 | public function getProperties ( $ id , & $ state_cache = null ) { if ( $ id === null || $ id === array ( ) ) { throw new InstanceDoesNotExistException ( 'State machine instance does not exist (null ID).' ) ; } $ q = $ this -> createQueryBuilder ( ) -> select ( null ) -> limit ( 1 ) ; $ this -> queryAddPropertiesSelect ... | Get all properties of state machine including it s state . |
54,945 | public function encodeProperties ( $ properties ) { foreach ( $ properties as $ k => & $ v ) { if ( isset ( $ this -> properties [ $ k ] ) ) { $ prop = $ this -> properties [ $ k ] ; if ( empty ( $ prop [ 'required' ] ) && ( $ v === array ( ) || ( is_string ( $ v ) && ctype_space ( $ v ) ) ) ) { $ v = null ; } } else {... | Encode properties to database representation . |
54,946 | public function decodeProperties ( $ properties ) { foreach ( $ this -> composed_properties as $ property => $ components ) { $ value = array ( ) ; foreach ( $ components as $ component => $ column ) { $ value [ $ component ] = isset ( $ properties [ $ column ] ) ? $ properties [ $ column ] : null ; } $ properties [ $ ... | Decode properties from database representation |
54,947 | public function isSupported ( array $ data ) { try { new DateTime ( $ data [ $ this -> getProperty ( ) ] ) ; } catch ( Exception $ e ) { return false ; } return true ; } | Is data supported? |
54,948 | private function getColumnAnnotation ( $ reflectionProperty ) { $ columnAnnotation = $ this -> getReader ( ) -> getPropertyAnnotation ( $ reflectionProperty , Column :: class ) ; if ( null === $ columnAnnotation ) { return null ; } return $ columnAnnotation -> type ; } | Get Column Annotation |
54,949 | public function thickbox ( ) { ?> <script type="text/javascript"> jQuery(document).ready(function ($) { $(document).on('click', '#ibd-wp-notifications-template-tags- <?php echo self :: $ count ; ?> ', function (e) { var tag = jQuery("#ibd-wp-notifications-add-tag-value- <?php echo self :: $ count ; ?> ").val()... | Render the thickbox . |
54,950 | public function display_template_tag_button ( ) { add_thickbox ( ) ; $ id = 'ibd-wp-notifications-select-tag-' . self :: $ count ; $ class = 'thickbox button ibd-wp-notifications-tags' ; $ title = $ this -> translations [ 'insertTemplateTag' ] ; echo '<a href="#TB_inline?width=150height=250&inlineId=' . $ id . '" class... | Display the template tag button button . |
54,951 | protected function ask ( $ question , $ default = null , $ validator = null ) { return $ this -> output -> ask ( $ question , $ default , $ validator ) ; } | To ask question |
54,952 | protected function call ( $ command , $ params = [ ] ) { $ parameters [ 'command' ] = $ command ; foreach ( $ params as $ key => $ value ) { $ parameters [ $ key ] = $ value ; } $ command = $ this -> getApplication ( ) -> find ( $ command ) ; return $ command -> run ( new ArrayInput ( $ parameters ) , $ this -> output ... | To call another console command |
54,953 | protected function createFile ( $ folder , $ filename , $ stubs , $ defaultFolder = '' ) { if ( ! empty ( $ folder = implode ( '/' , $ folder ) ) ) { $ dir = app_path ( ) . "{$defaultFolder}/{$folder}" ; $ this -> filesystem -> createDirectory ( $ dir ) ; $ this -> filesystem -> create ( "{$dir}/{$filename}.php" , $ st... | Create file from stubs |
54,954 | protected function _setRenderer ( $ renderer ) { if ( $ renderer !== null && ! ( $ renderer instanceof RendererInterface ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Invalid renderer' ) , null , null , $ renderer ) ; } $ this -> renderer = $ renderer ; } | Sets the renderer for this instance . |
54,955 | public function append ( $ list = null ) { if ( is_string ( $ list ) ) { $ this -> _list [ ] = $ list ; } if ( is_array ( $ list ) ) { $ this -> _list = array_merge ( $ this -> _list , $ list ) ; } return $ this ; } | Append Path or List to List |
54,956 | public function get ( $ js = null , $ compress = true ) { if ( null === $ js ) { foreach ( ( array ) $ this -> _list as $ src ) { if ( ! file_exists ( $ src ) ) { continue ; } $ js .= file_get_contents ( $ src ) ; } } $ this -> _list = [ ] ; return $ compress ? $ this -> parse ( $ js ) : $ js ; } | Get Packed JavaScript |
54,957 | public function save ( $ dest = null , $ compress = true ) { if ( ! file_exists ( dirname ( $ dest ) ) ) { mkdir ( dirname ( $ dest ) , 0755 , true ) ; } file_put_contents ( $ dest , $ this -> get ( null , $ compress ) ) ; } | Save JavaScript to File |
54,958 | public function getWebPath ( ) { return sprintf ( '%s%s%s' , $ this -> load ( 'assetsWebPath' ) , $ this -> file -> getStorePath ( ) , $ this -> file -> getName ( ) ) ; } | Return Media web path . |
54,959 | protected function bbcode_action ( $ tag , $ part , $ position , $ tag_extended = false ) { for ( $ i = 1 ; $ i <= $ this -> array_size ; $ i ++ ) { if ( $ this -> bbcode_list [ $ this -> array_size - $ i ] [ 'bbcode_tag' ] == $ tag ) { if ( ! $ this -> bbcode_list [ $ this -> array_size - $ i ] [ $ part ] ) { $ this -... | Add position to a listed bbcode |
54,960 | public function remove_bbcodes_after ( ) { for ( $ i = 1 ; $ i <= $ this -> array_size ; $ i ++ ) { if ( $ this -> bbcode_list [ $ this -> array_size - $ i ] [ 'open_start' ] >= $ this -> trim_position ) { unset ( $ this -> bbcode_list [ $ this -> array_size - $ i ] ) ; } } $ this -> array_size = sizeof ( $ this -> bbc... | Removes all BBcodes after a given position |
54,961 | public function get_open_bbcodes_after ( $ position ) { $ bbcodes = array ( ) ; for ( $ i = 1 ; $ i <= $ this -> array_size ; $ i ++ ) { if ( ( $ this -> bbcode_list [ $ this -> array_size - $ i ] [ 'open_start' ] < $ position ) && ( $ this -> bbcode_list [ $ this -> array_size - $ i ] [ 'close_start' ] >= $ position )... | Returns an array with BBCodes that need to be closed after the position . |
54,962 | public function get_content_position ( $ content , $ allowed_length ) { $ content = $ this -> restore_square_brackets_in_smilies ( $ content ) ; if ( utf8_strpos ( utf8_substr ( $ content , 0 , $ allowed_length ) , '<' ) === false ) { return $ allowed_length ; } $ content_length = $ allowed_length ; $ start_position = ... | Get the position in the text where we need to cut the message . |
54,963 | protected function replace_square_brackets_in_smilies ( ) { if ( utf8_strpos ( $ this -> message , '<' ) !== false ) { $ this -> bracket_replacement = '{' . md5 ( $ this -> message ) . '}' ; while ( utf8_strpos ( $ this -> message , $ this -> bracket_replacement ) !== false ) { $ this -> bracket_replacement = '{' . $ t... | Replace square brackets in smiley codes |
54,964 | public function encode ( $ numbers ) { if ( ! is_array ( $ numbers ) ) { $ numbers = [ $ numbers ] ; } if ( $ this -> signed ) { $ numbers = Signed :: encodeBlock ( $ numbers ) ; } $ digits = [ ] ; $ bits = $ this -> bits ; $ cBit = $ this -> cBit ; foreach ( $ numbers as $ number ) { do { $ digit = ( $ number % $ this... | Encodes a block of numbers to a VLQ - sequence |
54,965 | public function decode ( array $ digits ) { $ result = [ ] ; $ current = 0 ; $ cBit = $ this -> cBit ; $ bits = $ this -> bits ; $ shift = 0 ; foreach ( $ digits as $ digit ) { $ current += ( ( $ digit % $ cBit ) << $ shift ) ; if ( $ digit < $ cBit ) { $ result [ ] = $ current ; $ current = 0 ; $ shift = 0 ; } else { ... | Decodes a VLQ - sequence to a block of numbers |
54,966 | private function registerObserver ( ) { if ( $ this -> observer ) { return ; } $ this -> observer = new \ chilimatic \ lib \ session \ observer \ Session ( $ this ) ; $ this -> engine -> attach ( $ this -> observer ) ; } | attaches the observer to the subject within the engine |
54,967 | public function extendQueryBuilder ( QueryBuilder $ queryBuilder ) { $ queryBuilder -> setFirstResult ( $ this -> getFirstResult ( ) ) -> setMaxResults ( $ this -> getLimit ( ) ) ; return $ this ; } | Extend Query Builder |
54,968 | protected function formatGatewayClassName ( $ name ) { if ( class_exists ( $ name ) ) { return $ name ; } $ name = $ this -> camelCase ( $ name ) ; return __NAMESPACE__ . "\\Gateways\\{$name}Gateway" ; } | Format gateway name . |
54,969 | protected function callCustomCreator ( $ gateway ) { return call_user_func ( $ this -> customCreators [ $ gateway ] , $ this -> config -> get ( $ gateway ) ) ; } | Call a custom gateway creator . |
54,970 | public function apply ( array $ properties ) { $ properties = $ this -> applyDefaultAttrValues ( $ properties ) ; foreach ( $ properties as $ key => $ value ) { if ( true === $ this -> isAttribute ( $ key ) ) { $ this -> set ( $ key , $ value ) ; continue ; } if ( true === $ this -> isEmbedHasOne ( $ key ) ) { if ( emp... | Applies an array of raw model properties to the model instance . |
54,971 | public function clear ( $ key ) { if ( true === $ this -> isAttribute ( $ key ) ) { return $ this -> setAttribute ( $ key , null ) ; } if ( true === $ this -> isEmbedHasOne ( $ key ) ) { return $ this -> setEmbedHasOne ( $ key , null ) ; } if ( true === $ this -> isEmbedHasMany ( $ key ) ) { $ collection = $ this -> ha... | Clears a property value . For an attribute will set the value to null . For collections will clear the collection contents . |
54,972 | public function createEmbedFor ( $ key ) { if ( false === $ this -> isEmbed ( $ key ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to create an Embed instance for property key "%s" - the property is not an embed.' , $ key ) ) ; } $ embedMeta = $ this -> getMetadata ( ) -> getEmbed ( $ key ) -> embedMeta ; $ emb... | Creates a new Embed model instance for the provided property key . |
54,973 | public function get ( $ key ) { if ( true === $ this -> isAttribute ( $ key ) ) { return $ this -> getAttribute ( $ key ) ; } if ( true === $ this -> isEmbed ( $ key ) ) { return $ this -> getEmbed ( $ key ) ; } } | Gets a model property . Returns null if the property does not exist on the model or is not set . |
54,974 | public function getChangeSet ( ) { return [ 'attributes' => $ this -> filterNotSavedProperties ( $ this -> attributes -> calculateChangeSet ( ) ) , 'embedOne' => $ this -> hasOneEmbeds -> calculateChangeSet ( ) , 'embedMany' => $ this -> hasManyEmbeds -> calculateChangeSet ( ) , ] ; } | Gets the current change set of properties . |
54,975 | public function initialize ( array $ properties = null ) { $ attributes = [ ] ; $ embedOne = [ ] ; $ embedMany = [ ] ; if ( null !== $ properties ) { $ attributes = $ this -> applyDefaultAttrValues ( $ attributes ) ; foreach ( $ properties as $ key => $ value ) { if ( true === $ this -> isAttribute ( $ key ) ) { $ attr... | Initializes the model and loads its attributes and relationships . |
54,976 | public function isDirty ( ) { return true === $ this -> attributes -> areDirty ( ) || true === $ this -> hasOneEmbeds -> areDirty ( ) || true === $ this -> hasManyEmbeds -> areDirty ( ) ; } | Determines if the model is currently dirty . |
54,977 | public function isEmbedHasMany ( $ key ) { if ( false === $ this -> isEmbed ( $ key ) ) { return false ; } return $ this -> getMetadata ( ) -> getEmbed ( $ key ) -> isMany ( ) ; } | Determines if a property key is a has - many embed . |
54,978 | public function isEmbedHasOne ( $ key ) { if ( false === $ this -> isEmbed ( $ key ) ) { return false ; } return $ this -> getMetadata ( ) -> getEmbed ( $ key ) -> isOne ( ) ; } | Determines if a property key is a has - one embed . |
54,979 | public function removeEmbed ( $ key , Embed $ embed ) { if ( false === $ this -> isEmbedHasMany ( $ key ) ) { return $ this ; } $ this -> touch ( ) ; $ collection = $ this -> hasManyEmbeds -> get ( $ key ) ; $ collection -> remove ( $ embed ) ; $ this -> doDirtyCheck ( ) ; return $ this ; } | Removes a specific Embed from a has - many embed collection . |
54,980 | public function rollback ( ) { $ this -> attributes -> rollback ( ) ; $ this -> hasOneEmbeds -> rollback ( ) ; $ this -> hasManyEmbeds -> rollback ( ) ; $ this -> doDirtyCheck ( ) ; return $ this ; } | Rolls back a model to its original values . |
54,981 | public function set ( $ key , $ value ) { if ( true === $ this -> isAttribute ( $ key ) ) { return $ this -> setAttribute ( $ key , $ value ) ; } if ( true === $ this -> isEmbed ( $ key ) ) { return $ this -> setEmbed ( $ key , $ value ) ; } } | Sets a model property . |
54,982 | protected function applyDefaultAttrValues ( array $ attributes = [ ] ) { foreach ( $ this -> getMetadata ( ) -> getAttributes ( ) as $ key => $ attrMeta ) { if ( ! isset ( $ attrMeta -> defaultValue ) || isset ( $ attributes [ $ key ] ) ) { continue ; } $ attributes [ $ key ] = $ this -> convertAttributeValue ( $ key ,... | Applies default attribute values from metadata if set . |
54,983 | protected function convertAttributeValue ( $ key , $ value ) { return $ this -> store -> convertAttributeValue ( $ this -> getDataType ( $ key ) , $ value ) ; } | Converts an attribute value to the appropriate data type . |
54,984 | protected function filterNotSavedProperties ( array $ properties ) { foreach ( $ this -> getMetadata ( ) -> getAttributes ( ) as $ fieldKey => $ propMeta ) { if ( true === $ propMeta -> shouldSave ( ) || ! isset ( $ properties [ $ fieldKey ] ) ) { continue ; } unset ( $ properties [ $ fieldKey ] ) ; } return $ properti... | Removes properties marked as non - saved . |
54,985 | protected function getAttribute ( $ key ) { if ( true === $ this -> isCalculatedAttribute ( $ key ) ) { return $ this -> getCalculatedAttribute ( $ key ) ; } $ this -> touch ( ) ; return $ this -> attributes -> get ( $ key ) ; } | Gets an attribute value . |
54,986 | protected function getCalculatedAttribute ( $ key ) { $ attrMeta = $ this -> getMetadata ( ) -> getAttribute ( $ key ) ; $ class = $ attrMeta -> calculated [ 'class' ] ; $ method = $ attrMeta -> calculated [ 'method' ] ; $ value = $ class :: $ method ( $ this ) ; return $ this -> convertAttributeValue ( $ key , $ value... | Gets a calculated attribute value . |
54,987 | protected function getEmbed ( $ key ) { if ( true === $ this -> isEmbedHasOne ( $ key ) ) { $ this -> touch ( ) ; return $ this -> hasOneEmbeds -> get ( $ key ) ; } if ( true === $ this -> isEmbedHasMany ( $ key ) ) { $ this -> touch ( ) ; return $ this -> hasManyEmbeds -> get ( $ key ) ; } return null ; } | Gets an embed value . |
54,988 | protected function isCalculatedAttribute ( $ key ) { if ( false === $ this -> isAttribute ( $ key ) ) { return false ; } return $ this -> getMetadata ( ) -> getAttribute ( $ key ) -> isCalculated ( ) ; } | Determines if an attribute key is calculated . |
54,989 | protected function setEmbed ( $ key , $ value ) { if ( true === $ this -> isEmbedHasOne ( $ key ) ) { return $ this -> setEmbedHasOne ( $ key , $ value ) ; } if ( true === $ this -> isEmbedHasMany ( $ key ) ) { throw new \ RuntimeException ( 'You cannot set a hasMany embed directly. Please access using pushEmbed(), cle... | Sets an embed value . |
54,990 | protected function setEmbedHasOne ( $ key , Embed $ embed = null ) { if ( null !== $ embed ) { $ this -> validateEmbedSet ( $ key , $ embed -> getName ( ) ) ; } $ this -> touch ( ) ; $ this -> hasOneEmbeds -> set ( $ key , $ embed ) ; $ this -> doDirtyCheck ( ) ; return $ this ; } | Sets a has - one embed . |
54,991 | public static function get ( $ slug ) { return isset ( self :: $ queues [ $ slug ] ) ? self :: $ queues [ $ slug ] : null ; } | Retrieve a queue . |
54,992 | protected function _extractContent ( $ tokenId , $ tokens ) { $ token = $ tokens [ $ tokenId ] ; $ body = $ this -> _controlContent ( $ tokenId , $ tokens ) ; $ line = $ token [ 'line' ] ; while ( -- $ tokenId >= 0 && $ tokens [ $ tokenId ] [ 'line' ] === $ line ) { $ body = $ tokens [ $ tokenId ] [ 'content' ] . $ bod... | Extract the Control content and its prefix |
54,993 | protected function _controlContent ( $ tokenId , $ tokens , $ root = true ) { $ token = $ tokens [ $ tokenId ] ; $ body = $ token [ 'content' ] ; foreach ( $ token [ 'children' ] as $ childrenId ) { if ( ! $ tokens [ $ childrenId ] [ 'children' ] ) { $ body .= $ tokens [ $ childrenId ] [ 'content' ] ; } elseif ( $ root... | Extract the control content |
54,994 | protected function _matchPattern ( $ patterns , $ body ) { foreach ( $ patterns as $ pattern ) { if ( preg_match ( String :: insert ( $ pattern , $ this -> _regexMap ) , $ body ) === 1 ) { return true ; } } return false ; } | Abstracts the matching out . Will return true if any of the patterns match correctly . |
54,995 | public function discover ( $ url , array $ args = [ ] ) { $ url = trim ( $ url ) ; $ html = HtmlExplorer :: fromWeb ( $ url , $ this -> http ) ; $ typePattern = '#^(' . join ( '|' , array_keys ( $ this -> formats ) ) . ')\+oembed$#' ; $ nodes = $ html -> findTags ( 'link' ) ; foreach ( $ nodes as $ node ) { $ rel = str... | Tries to fetch data for the given content URL using discovery . |
54,996 | public function fetch ( $ url , $ endpoint , array $ args = [ ] ) { $ url = trim ( $ url ) ; $ endpoint = trim ( $ endpoint ) ; foreach ( $ this -> formats as $ type => $ parser ) { $ type = explode ( '/' , $ type ) ; $ result = $ this -> queryProvider ( $ endpoint , $ url , $ type [ 1 ] , $ args ) ; if ( $ result -> s... | Fetches the data for the given content URL . |
54,997 | public function getHtml ( $ url , $ endpoint = null , array $ args = [ ] ) { if ( $ endpoint !== null ) { $ data = $ this -> fetch ( $ url , $ endpoint , $ args ) ; } else { $ data = $ this -> discover ( $ url , $ args ) ; } if ( ! $ data ) { return false ; } return $ this -> toHtml ( $ data ) ; } | Returns the HTML representation for the given content URL . |
54,998 | public function toHtml ( $ data ) { if ( ! is_object ( $ data ) && ! is_array ( $ data ) ) { throw new \ InvalidArgumentException ( 'The $data parameter takes only an object or an array.' ) ; } $ data = ( array ) $ data ; $ type = ( string ) $ data [ 'type' ] ; switch ( $ type ) { case 'photo' : if ( empty ( $ data [ '... | Generates an HTML code from the given data . |
54,999 | public function queryProvider ( $ endpoint , $ url = null , $ format = 'json' , array $ args = [ ] ) { if ( $ url !== null ) { if ( $ format === null ) { throw new \ InvalidArgumentException ( 'The request format must be defined in manual mode.' ) ; } $ args [ 'url' ] = ( string ) $ url ; $ args [ 'format' ] = ( string... | Queries the oEmbed endpoint of the provider . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.