idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
23,600 | public function setRedirectUrl ( $ redirectUrl ) { if ( ! $ this -> getUrlValidator ( ) -> isValid ( $ redirectUrl ) ) { throw new InvalidArgumentException ( 'URL provided is invalid' ) ; } $ this -> redirectUrl = $ redirectUrl ; } | Set the Redirect URL |
23,601 | public function setRequestUrl ( $ requestUrl ) { if ( ! $ this -> getUrlValidator ( ) -> isValid ( $ requestUrl ) ) { throw new InvalidArgumentException ( 'URL provided is invalid' ) ; } $ this -> requestUrl = $ requestUrl ; } | Set the Request URL to redirect |
23,602 | public function setSite ( $ site ) { if ( $ site === null ) { $ this -> siteId = null ; $ this -> site = null ; return ; } $ this -> siteId = $ site -> getSiteId ( ) ; $ this -> site = $ site ; } | Set the Site the redirect belongs to |
23,603 | public static function removeMemorizedValue ( $ fieldId = null ) { if ( isset ( $ _SESSION [ '_FIELDS' ] ) ) { if ( is_null ( $ fieldId ) ) { $ _SESSION [ '_FIELDS' ] = null ; unset ( $ _SESSION [ '_FIELDS' ] ) ; } else { unset ( $ _SESSION [ '_FIELDS' ] [ $ fieldId ] ) ; } } } | Removes the specified fieldId from memory or clears the entire memorized fields if not set . |
23,604 | public function buildObject ( $ instance = null ) { if ( is_null ( $ instance ) ) { return ( object ) $ this -> fields ; } foreach ( $ this -> fields as $ property => $ value ) { $ method = 'set' . ucwords ( $ property ) ; if ( is_callable ( [ $ instance , $ method ] ) ) { $ instance -> { $ method } ( $ value ) ; } } } | Tries to set values to the specified object using available setter methods . |
23,605 | public function loadUserByUsername ( $ username ) { $ slackUser = $ this -> client -> getSlackUserFromOAuthCode ( $ username ) ; if ( ! $ slackUser -> isValid ( ) ) { throw new UsernameNotFoundException ( 'No access token found.' ) ; } $ user = $ this -> userService -> findBySlackUserId ( $ slackUser -> getUserId ( ) ) ; if ( ! empty ( $ user ) ) { return $ user ; } $ user = $ this -> userService -> findUserByEmail ( $ slackUser -> getEmail ( ) ) ; if ( ! empty ( $ user ) ) { $ user -> setSlackUserId ( $ slackUser -> getUserId ( ) ) ; return $ user ; } return $ this -> registerUser ( $ slackUser ) ; } | Fetches the user from slack |
23,606 | public function materialDesignColorPaletteBackgroundFunction ( array $ args = [ ] ) { return $ this -> materialDesignColorPalette ( "bg" , ArrayHelper :: get ( $ args , "name" ) , ArrayHelper :: get ( $ args , "value" ) ) ; } | Displays a Material Design Color Palette background . |
23,607 | public function materialDesignColorPaletteTextFunction ( array $ args = [ ] ) { return $ this -> materialDesignColorPalette ( "text" , ArrayHelper :: get ( $ args , "name" ) , ArrayHelper :: get ( $ args , "value" ) ) ; } | Displays a Material Design Color Palette text . |
23,608 | public function silentLogin ( Authenticatable $ user ) { $ this -> updateSession ( $ user -> getAuthIdentifier ( ) ) ; $ this -> setUser ( $ user ) ; } | Login the user into the app without firing the Login event . |
23,609 | public function massUpdate ( ArticlesRequest $ request ) { $ this -> authorize ( 'otherUpdate' , $ this -> model ) ; $ articles = $ this -> model -> whereIn ( 'id' , $ request -> articles ) ; $ messages = [ ] ; switch ( $ request -> mass_action ) { case 'published' : if ( ! $ articles -> update ( [ 'state' => 'published' ] ) ) { $ messages [ ] = 'unable to published' ; } break ; case 'unpublished' : if ( ! $ articles -> update ( [ 'state' => 'unpublished' ] ) ) { $ messages [ ] = 'unable to unpublished' ; } break ; case 'draft' : if ( ! $ articles -> update ( [ 'state' => 'draft' ] ) ) { $ messages [ ] = 'unable to draft' ; } break ; case 'on_mainpage' : if ( ! $ articles -> update ( [ 'on_mainpage' => 1 ] ) ) { $ messages [ ] = 'unable to mainpage' ; } break ; case 'not_on_mainpage' : if ( ! $ articles -> update ( [ 'on_mainpage' => 0 ] ) ) { $ messages [ ] = 'unable to not_on_mainpage' ; } break ; case 'allow_com' : if ( ! $ articles -> update ( [ 'allow_com' => 1 ] ) ) { $ messages [ ] = 'unable to allow_com' ; } break ; case 'disallow_com' : if ( ! $ articles -> update ( [ 'allow_com' => 0 ] ) ) { $ messages [ ] = 'unable to disallow_com' ; } break ; case 'currdate' : $ articles -> timestamps = false ; if ( ! $ articles -> update ( [ 'created_at' => date ( 'Y-m-d H:i:s' ) , 'updated_at' => null ] ) ) { $ messages [ ] = 'unable to currdate' ; } $ articles -> timestamps = true ; break ; case 'delete' : if ( ! $ articles -> get ( ) -> each -> delete ( ) ) { $ messages [ ] = 'unable to delete' ; } break ; case 'delete_drafts' : if ( ! $ articles -> where ( 'state' , 'draft' ) -> get ( ) -> each -> delete ( ) ) { $ messages [ ] = 'unable to delete_drafts' ; } break ; } $ message = empty ( $ messages ) ? 'msg.complete' : 'msg.complete_but_null' ; return $ this -> makeRedirect ( true , 'admin.articles.index' , $ message ) ; } | Mass updates to Article . |
23,610 | public function findByRequestParams ( Request \ Params $ params ) { if ( empty ( $ params -> pagination ) && isset ( $ params -> resourceConfig ) && isset ( $ params -> resourceConfig -> defaults ) && isset ( $ params -> resourceConfig -> defaults -> pagination ) && ! $ params -> resourceConfig -> defaults -> pagination ) { return $ this -> findAll ( $ params -> primaryClass , $ params -> filters , $ params -> sorting , $ params -> translatable ) ; } else { return $ this -> findPaginated ( $ params -> primaryClass , $ params -> filters , $ params -> sorting , $ params -> getPageOffset ( ) , $ params -> getPageSize ( ) , $ params -> translatable ) ; } } | Helper method to paginate a query using the HATEOAS request parameters . |
23,611 | public function findPaginated ( $ entityClass , array $ criteria , $ sorting = [ ] , $ offset = Request \ Params :: DEFAULT_PAGE_OFFSET , $ limit = Request \ Params :: DEFAULT_PAGE_SIZE , $ translatable = false ) { $ qb = $ this -> getQueryBuilder ( $ entityClass , $ criteria , $ sorting , $ translatable ) ; $ qb -> setFirstResult ( $ offset ) -> setMaxResults ( $ limit ) ; $ paginator = new Paginator ( $ qb -> getQuery ( ) ) ; $ collection = new PaginatedCollection ( $ paginator ) ; return $ collection ; } | Helper method to paginate find by queries . |
23,612 | public function getPluginController ( $ pluginName ) { if ( $ this -> serviceManager -> has ( $ pluginName ) ) { $ serviceManager = $ this -> serviceManager ; } else { $ serviceManager = $ this -> serviceManager -> get ( 'ControllerLoader' ) ; } if ( ! $ serviceManager -> has ( $ pluginName ) ) { throw new InvalidPluginException ( "Plugin $pluginName is not loaded or configured. Check config/application.config.php" ) ; } $ pluginController = $ serviceManager -> get ( $ pluginName ) ; if ( ! $ pluginController instanceof PluginInterface ) { throw new InvalidPluginException ( 'Class "' . get_class ( $ pluginController ) . '" for plugin "' . $ pluginName . '" does not implement ' . '\Rcm\Plugin\PluginInterface' ) ; } return $ pluginController ; } | Get an instantiated plugin controller |
23,613 | public function handleResponseFromPluginController ( ResponseInterface $ response , $ blockInstanceName ) { foreach ( $ response -> getHeaders ( ) as $ header ) { header ( $ header -> toString ( ) ) ; } echo $ response -> getContent ( ) ; exit ; } | Handles the legacy support for the odd case where plugin controllers return zf2 responses instead of view models |
23,614 | public function getRevisionDbInfo ( $ siteId , $ name , $ revisionId ) { $ queryBuilder = $ this -> _em -> createQueryBuilder ( ) -> select ( 'container,' . 'publishedRevision.revisionId,' . 'revision,' . 'pluginWrappers,' . 'pluginInstances' ) -> from ( \ Rcm \ Entity \ Container :: class , 'container' ) -> leftJoin ( 'container.publishedRevision' , 'publishedRevision' ) -> leftJoin ( 'container.site' , 'site' ) -> leftJoin ( 'container.revisions' , 'revision' ) -> leftJoin ( 'revision.pluginWrappers' , 'pluginWrappers' ) -> leftJoin ( 'pluginWrappers.instance' , 'pluginInstances' ) -> where ( 'site.siteId = :siteId' ) -> andWhere ( 'container.name = :containerName' ) -> andWhere ( 'revision.revisionId = :revisionId' ) -> orderBy ( 'pluginWrappers.renderOrder' , 'ASC' ) -> setParameter ( 'siteId' , $ siteId ) -> setParameter ( 'containerName' , $ name ) -> setParameter ( 'revisionId' , $ revisionId ) ; $ getData = $ queryBuilder -> getQuery ( ) -> getSingleResult ( Query :: HYDRATE_ARRAY ) ; $ result = null ; if ( ! empty ( $ getData ) ) { $ result = $ getData [ 0 ] ; $ result [ 'revision' ] = $ result [ 'revisions' ] [ $ revisionId ] ; unset ( $ result [ 'revisions' ] , $ getData ) ; } return $ result ; } | Get Revision DB Info |
23,615 | protected function getFilters ( Request $ request ) { $ type = $ this -> getFilterType ( $ request ) ; if ( ! $ type ) { return $ request -> query -> get ( 'search' ) [ 'value' ] ; } $ filter = new $ type ( ) ; $ param = $ filter -> getBlockPrefix ( ) ; return $ request -> query -> get ( $ param ) ; } | Extracts the filters from the request s query parameters . |
23,616 | protected function getLimit ( Request $ request ) { return min ( $ this -> getMaxLimit ( $ request ) , $ request -> query -> get ( 'length' , $ this -> getDefaultLimit ( $ request ) ) ) ; } | Defines the limit for the Propel query . |
23,617 | protected function getOffset ( Request $ request ) { return max ( $ request -> query -> get ( 'start' , 0 ) , $ this -> getDefaultOffset ( $ request ) ) ; } | Defines the offset for the Propel query . |
23,618 | protected function search ( ModelCriteria $ query , Request $ request ) { $ filters = $ this -> getFilters ( $ request ) ; if ( empty ( $ filters ) ) { return $ query ; } $ conditions = array ( ) ; $ columns = $ this -> getSearchColumns ( $ request ) ; if ( is_array ( $ filters ) ) { foreach ( $ columns as $ name => $ condition ) { $ items = explode ( '.' , $ name ) ; $ i = 0 ; $ values = $ filters ; while ( is_array ( $ values ) && array_key_exists ( $ items [ $ i ] , $ values ) ) { $ values = $ values [ $ items [ $ i ] ] ; $ i ++ ; } if ( is_array ( $ values ) ) { continue ; } else { $ value = trim ( $ values ) ; } if ( empty ( $ value ) && ! is_numeric ( $ value ) ) { continue ; } $ query -> condition ( 'search_' . $ name , sprintf ( $ condition , $ value ) ) ; $ conditions [ ] = 'search_' . $ name ; } if ( ! empty ( $ conditions ) ) { return $ query -> where ( $ conditions , 'and' ) ; } } else { $ value = trim ( $ filters ) ; foreach ( $ columns as $ name => $ condition ) { $ query -> condition ( 'search_' . $ name , sprintf ( $ condition , $ value ) ) ; $ conditions [ ] = 'search_' . $ name ; } if ( ! empty ( $ conditions ) ) { return $ query -> where ( $ conditions , 'or' ) ; } } } | Filters the database records . This method should be considered final for all practical purposes . |
23,619 | protected function sort ( ModelCriteria $ query , Request $ request ) { $ order = $ this -> getSortOrder ( $ request ) ; foreach ( $ order as $ setting ) { $ column = $ setting [ 0 ] ; $ direction = $ setting [ 1 ] ; $ query -> orderBy ( $ column , $ direction ) ; } return $ query ; } | Sorts the database records . This method should be considered final for all practical purposes . |
23,620 | protected function getSortOrder ( Request $ request ) { $ sort = array ( ) ; $ order = $ request -> query -> get ( 'order' , array ( ) ) ; $ columns = $ this -> getSortColumns ( $ request ) ; foreach ( $ order as $ setting ) { $ index = $ setting [ 'column' ] ; if ( array_key_exists ( $ index , $ columns ) ) { $ column = $ columns [ $ index ] ; if ( ! is_array ( $ column ) ) { $ column = array ( $ column ) ; } foreach ( $ column as $ c ) { $ sort [ ] = array ( $ c , $ setting [ 'dir' ] , ) ; } } } if ( empty ( $ sort ) ) { $ sort = $ this -> getDefaultSortOrder ( $ request ) ; } return $ sort ; } | Computes the sort order . This method should be considered final for all practical purposes . |
23,621 | public function sort ( callable $ callback , bool $ keySort = false ) : self { $ keys = $ this -> keys ; $ values = $ this -> values ; if ( $ keySort ) { uasort ( $ keys , $ callback ) ; $ values = array_replace ( $ keys , $ values ) ; } else { uasort ( $ values , $ callback ) ; $ keys = array_replace ( $ values , $ keys ) ; } $ this -> keys = array_values ( $ keys ) ; $ this -> values = array_values ( $ values ) ; return $ this ; } | Sorts this hash map using retrieved callback |
23,622 | private static function stringifyArrayKey ( array $ key ) : string { ksort ( $ key ) ; foreach ( $ key as & $ value ) { if ( is_array ( $ value ) ) { $ value = self :: stringifyArrayKey ( $ value ) ; } elseif ( is_object ( $ value ) ) { $ value = self :: stringifyKey ( $ value ) ; } } return json_encode ( $ key ) ; } | Calculates string representing specified array key |
23,623 | private static function stringifyKey ( $ key ) : string { if ( $ key === null || is_scalar ( $ key ) ) { return ( string ) $ key ; } if ( is_object ( $ key ) ) { return spl_object_hash ( $ key ) ; } return static :: stringifyArrayKey ( $ key ) ; } | Calculates string representing specified key |
23,624 | public function addMenuItem ( $ image , $ title , $ url ) { return $ this -> row -> addItem ( new \ Ease \ Html \ ATag ( $ url , new \ Ease \ TWB \ Col ( 2 , "$title<center><img class=\"img-responsive\" src=\"$image\" alt=\"$title\"></center>" ) ) ) ; } | Add Item to mainpage Menu |
23,625 | public function sign ( $ url , $ expires = null , $ options = [ ] ) { if ( parse_url ( $ url , PHP_URL_QUERY ) ) { throw new \ InvalidArgumentException ( 'This signer do not accept URL with query string' ) ; } if ( ! $ expires ) { $ expires = time ( ) + $ this -> options [ 'default_age' ] ; } return $ url . '?' . $ this -> makeQueryString ( $ this -> makeQueryParams ( $ url , $ expires , $ options ) ) ; } | Create a new URL Signer instance . |
23,626 | protected function getDispatcher ( ) : IDispatcher { if ( $ this -> dispatcher === null ) { $ this -> dispatcher = new Dispatcher ( ) ; } return $ this -> dispatcher ; } | Get the dispatcher |
23,627 | public function handle ( string $ pattern , callable $ resolver , int $ priority = 0 ) : Route { $ this -> cache = [ ] ; return $ this -> collection -> createRoute ( $ pattern , $ resolver ) -> set ( 'priority' , $ priority ) ; } | Register a new view |
23,628 | public function resolveViewName ( string $ name ) : ? string { if ( ! array_key_exists ( $ name , $ this -> cache ) ) { $ this -> collection -> sort ( ) ; $ view = $ this -> getRouter ( ) -> route ( new Context ( $ name ) ) ; if ( ! is_string ( $ view ) ) { $ view = null ; } $ this -> cache [ $ name ] = $ view ; } return $ this -> cache [ $ name ] ; } | Resolve a view s name |
23,629 | protected function scandirTask ( Context $ context , string $ path ) : \ Generator { $ entries = yield $ this -> pool -> submit ( $ context , new MethodCall ( static :: class , 'scandirJob' , $ path ) ) ; if ( $ entries === null ) { throw new FilesystemException ( \ sprintf ( 'Failed to scan directory: "%s"' , $ path ) ) ; } return $ entries ; } | Scan the given directory for items . |
23,630 | protected static function scandirJob ( string $ path ) : ? array { if ( ! \ is_dir ( $ path ) ) { return null ; } $ entries = @ \ glob ( $ path . \ DIRECTORY_SEPARATOR . '*' , \ GLOB_NOSORT ) ; return ( $ entries === false ) ? null : $ entries ; } | Scan the given directory using sync fuctions . |
23,631 | protected function readStreamTask ( Context $ context , string $ path ) : \ Generator { if ( ! yield $ this -> pool -> submit ( $ context , new MethodCall ( static :: class , 'checkFileReadableJob' , $ path ) ) ) { throw new FilesystemException ( \ sprintf ( 'File is not readable: "%s"' , $ path ) ) ; } if ( ! $ this -> fileTransferSupported ) { return new ReadableFileStream ( $ this -> pool , $ path ) ; } $ file = yield $ this -> pool -> submit ( $ context , new MethodCall ( FileDescriptor :: class , 'open' , $ path , 'rb' ) ) ; return new ReadableDescriptorStream ( $ this -> pool , $ path , $ file ) ; } | Open a file descriptor stream to be used for reading . |
23,632 | protected static function checkFileReadableJob ( string $ path ) : bool { if ( ! \ is_file ( $ path ) || ! \ is_readable ( $ path ) ) { return false ; } return true ; } | Check if the given path is a regular file that is readable . |
23,633 | protected function writeStreamTask ( Context $ context , string $ path , bool $ append = false ) : \ Generator { if ( ! yield $ this -> pool -> submit ( $ context , new MethodCall ( static :: class , 'checkFileWritableJob' , $ path , ! $ append && ! $ this -> fileTransferSupported ) ) ) { throw new FilesystemException ( \ sprintf ( 'File is not writable: "%s"' , $ path ) ) ; } if ( ! $ this -> fileTransferSupported ) { return new WritableFileStream ( $ this -> pool , $ path ) ; } $ file = yield $ this -> pool -> submit ( $ context , new MethodCall ( FileDescriptor :: class , 'open' , $ path , $ append ? 'ab' : 'wb' ) ) ; return new WritableDescriptorStream ( $ this -> pool , $ path , $ file ) ; } | Open a file descriptor stream to be used for writing . |
23,634 | protected static function checkFileWritableJob ( string $ path , bool $ truncate = false ) : bool { if ( \ file_exists ( $ path ) && ( ! \ is_file ( $ path ) || ! \ is_writable ( $ path ) ) ) { return false ; } if ( $ truncate && \ is_file ( $ path ) ) { @ \ ftruncate ( @ \ fopen ( $ path , 'wb' ) , 0 ) ; } return true ; } | Check if the given path is a regular file that is writable . |
23,635 | public function url ( $ file , array $ params ) { $ cacheFileSrc = $ this -> make ( $ file , $ params ) ; return $ cacheFileSrc ? $ cacheFileSrc : null ; } | Creates and caches the image thumbnail and returns image url |
23,636 | private function urlPlaceholder ( $ width , $ height , $ text , $ backgroundColor , $ textColor , $ textSize , $ random , array $ options ) { if ( $ random ) { $ backgroundColor = $ this -> getRandomColor ( ) ; } $ src = 'https://placeholdit.imgix.net/~text?txtsize=' . $ textSize . '&bg=' . str_replace ( '#' , '' , $ backgroundColor ) . '&txtclr=' . str_replace ( '#' , '' , $ textColor ) . '&txt=' . $ text . '&w=' . $ width . '&h=' . $ height ; if ( ! $ this -> options [ 'placeholder' ] [ 'cache' ] ) { return Html :: img ( $ src , $ options ) ; } $ cacheFileName = md5 ( $ width . $ height . $ text . $ backgroundColor . $ textColor . $ textSize ) ; $ cacheFileExt = '.jpg' ; $ cacheFileDir = '/' . substr ( $ cacheFileName , 0 , 2 ) ; $ cacheFilePath = Yii :: getAlias ( $ this -> cachePath ) . $ cacheFileDir ; $ cacheFile = $ cacheFilePath . '/' . $ cacheFileName . $ cacheFileExt ; $ cacheUrl = str_replace ( '\\' , '/' , preg_replace ( '/^@[a-z]+/' , '' , $ this -> cachePath ) . $ cacheFileDir . '/' . $ cacheFileName . $ cacheFileExt ) ; if ( file_exists ( $ cacheFile ) ) { if ( $ this -> cacheExpire !== 0 && ( time ( ) - filemtime ( $ cacheFile ) ) > $ this -> cacheExpire ) { unlink ( $ cacheFile ) ; } else { return Html :: img ( $ cacheUrl , $ options ) ; } } if ( ! is_dir ( $ cacheFilePath ) ) { mkdir ( $ cacheFilePath , 0755 , true ) ; } $ image = file_get_contents ( $ src ) ; file_put_contents ( $ cacheFile , $ image ) ; return Html :: img ( $ cacheUrl , $ options ) ; } | Return URL placeholder image |
23,637 | private function jsPlaceholder ( $ width , $ height , $ text , $ backgroundColor , $ textColor , $ random , array $ options ) { $ src = 'holder.js/' . $ width . 'x' . $ height . '?bg=' . $ backgroundColor . '&fg=' . $ textColor . '&text=' . $ text ; if ( $ random ) { $ src .= $ src . '&random=yes' ; } return Html :: img ( '' , array_merge ( $ options , [ 'data-src' => $ src ] ) ) ; } | Return JS placeholder image |
23,638 | private function thumbnail ( array $ params ) { $ mode = isset ( $ params [ 'mode' ] ) ? $ params [ 'mode' ] : self :: THUMBNAIL_OUTBOUND ; $ width = ( isset ( $ params [ 'width' ] ) && is_numeric ( $ params [ 'width' ] ) ) ? $ params [ 'width' ] : null ; $ height = ( isset ( $ params [ 'height' ] ) && is_numeric ( $ params [ 'height' ] ) ) ? $ params [ 'height' ] : null ; if ( is_null ( $ width ) || is_null ( $ height ) ) { throw new Exception ( 'Wrong thumbnail width or height' ) ; } $ this -> image = $ this -> image -> thumbnail ( new Box ( $ width , $ height ) , $ mode ) ; } | Make thumbnail image |
23,639 | public function getDashletFields ( ) { $ extraClasses = MultiValueTextField :: create ( 'ExtraClasses' ) ; $ fields = new FieldList ( new TextField ( 'Title' , _t ( 'Dashlet.TITLE' , 'Title' ) ) , $ extraClasses ) ; $ this -> extend ( 'updateDashletFields' , $ fields ) ; return $ fields ; } | Gets the fields used for editing this dashlet on the frontend |
23,640 | public function canCreate ( $ member = null ) { if ( ! $ member ) { $ member = singleton ( 'SecurityContext' ) -> getMember ( ) ; } if ( $ member ) { $ allowed = Config :: inst ( ) -> get ( 'DashboardController' , 'allowed_dashlets' ) ; if ( in_array ( get_class ( $ this ) , $ allowed ) ) { return true ; } $ config = SiteConfig :: current_site_config ( ) ; $ required = $ this -> requiredPermission ( ) ; if ( $ config -> hasMethod ( 'checkPerm' ) && $ config -> checkPerm ( $ required ) ) { return true ; } } return parent :: canCreate ( $ member ) ; } | Can this dashlet be created by the current user? |
23,641 | public function save ( ) { if ( $ this -> widget && $ this -> widget -> OwnerID && $ this -> widget -> OwnerID != Member :: currentUserID ( ) ) { return ; } $ obj = self :: get ( ) -> byID ( $ this -> request -> param ( 'ID' ) ) ; $ obj -> PosX = $ this -> request -> postVar ( 'col' ) ; $ obj -> PosY = $ this -> request -> postVar ( 'row' ) ; $ obj -> Width = $ this -> request -> postVar ( 'size_x' ) ; $ obj -> Height = $ this -> request -> postVar ( 'size_y' ) ; $ obj -> write ( ) ; } | Called on every instance of resize . stop and draggable . stop in dashboards . js Takes the parameters and saves them to dashlet of the ID given . Values are automatically escaped . |
23,642 | public function updateDashboard ( ) { $ dashboardId = ( int ) $ this -> request -> postVar ( 'dashboard' ) ; $ items = ( array ) $ this -> request -> postVar ( 'order' ) ; if ( $ dashboardId ) { $ dashboard = $ this -> dataService -> memberDashboardById ( $ dashboardId ) ; if ( $ dashboard && $ dashboard -> exists ( ) ) { $ dashboard -> Widgets ( ) -> removeAll ( ) ; if ( is_array ( $ items ) ) { foreach ( $ items as $ i => $ widgetId ) { $ widget = $ this -> dataService -> dashletById ( $ widgetId ) ; if ( $ widget ) { $ widget -> ParentID = $ dashboard -> ID ; $ widget -> Sort = $ i + 1 ; $ widget -> write ( ) ; } } } } } } | Called to update a dashboard structure |
23,643 | protected function getRecord ( ) { $ id = ( int ) $ this -> request -> param ( 'ID' ) ; if ( ! $ id ) { $ id = ( int ) $ this -> request -> requestVar ( 'ID' ) ; } if ( $ id ) { $ type = $ this -> stat ( 'model_class' ) ; $ action = $ this -> request -> param ( 'Action' ) ; if ( $ action == 'dashlet' || $ action == 'widget' ) { $ type = 'Dashlet' ; } $ item = $ this -> dataService -> byId ( $ type , $ id ) ; if ( $ item instanceof DashboardPage ) { $ item -> setController ( $ this ) ; } return $ item ; } } | Overridden to make sure the dashboard page is attached to the correct controller |
23,644 | public function updateField ( $ primaryKey , $ field , $ value = null ) : bool { $ query = $ this -> query ( ) -> update ( ) -> set ( [ $ field => $ value , ] ) -> where ( [ $ this -> primaryKey ( ) => $ primaryKey , ] ) ; $ statement = $ query -> execute ( ) ; $ success = $ statement -> rowCount ( ) > 0 ; $ statement -> closeCursor ( ) ; return $ success ; } | Updates a single field for the given primaryKey |
23,645 | public function index ( $ params = [ ] , $ optParams = [ ] ) { if ( $ optParams instanceof IndexParams ) { $ optParams = $ optParams -> toArray ( true ) ; } return $ this -> sendRequest ( [ ] , [ 'restAction' => 'index' , 'params' => $ params , 'getParams' => $ optParams , ] , function ( $ response ) { $ backups = [ ] ; if ( isset ( $ response -> data [ 'items' ] ) ) { foreach ( $ response -> data [ 'items' ] as $ superbackup ) { $ backups [ ] = new SuperBackup ( $ superbackup ) ; } } return new Index ( [ 'models' => $ backups , 'nextPageToken' => $ response -> data [ 'nextPageToken' ] , ] ) ; } ) ; } | Fetches all existing backups . |
23,646 | public function create ( $ params , $ optParams = [ ] ) { if ( ! $ params instanceof SuperBackup ) { throw new InvalidParamException ( SuperBackup :: class . ' is required!' ) ; } if ( ! isset ( $ optParams [ 'cloud' ] ) ) { $ optParams [ 'cloud' ] = [ ] ; } $ optParams [ 'cloud' ] [ 'id' ] = $ params -> cloud -> id ; return $ this -> sendRequest ( [ ] , [ 'restAction' => 'create' , 'uri' => '/c/<cloud.id>' , 'postParams' => $ params -> toArray ( ) , 'getParams' => $ optParams , ] , function ( $ response ) { return isset ( $ response -> data ) ? new SuperBackup ( $ response -> data ) : $ response ; } ) ; } | Creates a new superbackup . |
23,647 | public function update ( $ params , $ optParams = [ ] ) { if ( ! $ params instanceof SuperBackup ) { throw new InvalidParamException ( SuperBackup :: class . ' is required!' ) ; } if ( ! isset ( $ optParams [ 'cloud' ] ) ) { $ optParams [ 'cloud' ] = [ ] ; } if ( $ params -> task && is_string ( $ params -> task -> type ) ) { $ params -> task = $ params -> task -> type ; } $ optParams [ 'cloud' ] [ 'id' ] = $ params -> cloud -> id ; return $ this -> sendRequest ( [ ] , [ 'restAction' => 'update' , 'uri' => '/c/<cloud.id>' , 'restId' => $ params -> id , 'postParams' => $ params -> toArray ( ) , 'getParams' => $ optParams , ] , function ( $ response ) { return isset ( $ response -> data ) ? new SuperBackup ( $ response -> data ) : $ response ; } ) ; } | Updates a superbackup . |
23,648 | public function delete ( $ params , $ optParams = [ ] ) { if ( $ params instanceof SuperBackup ) { $ params = $ params -> id ; } if ( ! isset ( $ optParams [ 'cloud' ] ) ) { $ optParams [ 'cloud' ] = [ ] ; } $ optParams [ 'cloud' ] [ 'id' ] = $ params ; return $ this -> sendRequest ( [ ] , [ 'restAction' => 'delete' , 'uri' => '/c/<cloud.id>' , 'restId' => $ params , 'getParams' => $ optParams , ] , function ( $ response ) { return $ response -> success ; } ) ; } | Deletes a superbackup . |
23,649 | public function view ( $ params , $ optParams = [ ] ) { if ( $ params instanceof SuperBackup ) { $ params = $ params -> id ; } if ( ! isset ( $ optParams [ 'cloud' ] ) ) { $ optParams [ 'cloud' ] = [ ] ; } $ optParams [ 'cloud' ] [ 'id' ] = $ params ; return $ this -> sendRequest ( [ ] , [ 'restAction' => 'view' , 'uri' => '/c/<cloud.id>' , 'getParams' => $ optParams , ] , function ( $ response ) { return isset ( $ response -> data ) ? new SuperBackup ( $ response -> data ) : $ response ; } ) ; } | Fetches a superbackup . |
23,650 | public static function render ( $ view , array $ context = [ ] , $ type = null ) { $ viewBuilder = static :: getViewBuilder ( ) ; $ viewObject = $ viewBuilder -> create ( $ view , $ type ) ; return $ viewObject -> render ( $ context ) ; } | Render a view for a given URI . |
23,651 | public function flat ( array $ properties ) : string { Assert :: isMap ( $ properties ) ; return $ this -> arrayImploder -> byGlue ( $ properties , ';' , ':' ) ; } | Flat a list of css properties . The list have to be in form of an associative array . |
23,652 | public function send ( $ data , array $ registrationIds = [ ] , array $ options = [ ] ) { $ this -> responses = [ ] ; $ data = array_merge ( $ options , [ 'data' => $ data , ] ) ; if ( isset ( $ options [ 'to' ] ) ) { $ this -> responses [ ] = $ this -> browser -> post ( $ this -> apiUrl , $ this -> getHeaders ( ) , json_encode ( $ data ) ) ; } elseif ( count ( $ registrationIds ) > 0 ) { $ chunks = array_chunk ( $ registrationIds , $ this -> registrationIdMaxCount ) ; foreach ( $ chunks as $ registrationIds ) { $ data [ 'registration_ids' ] = $ registrationIds ; $ this -> responses [ ] = $ this -> browser -> post ( $ this -> apiUrl , $ this -> getHeaders ( ) , json_encode ( $ data ) ) ; } } $ this -> client -> flush ( ) ; foreach ( $ this -> responses as $ response ) { $ message = json_decode ( $ response -> getContent ( ) ) ; if ( $ message === null || $ message -> success == 0 || $ message -> failure > 0 ) { return false ; } } return true ; } | Sends the message via the GCM server . |
23,653 | public function sendTo ( $ data , $ topic = '/topics/global' , array $ options = [ ] ) { $ options [ 'to' ] = $ topic ; return $ this -> send ( $ data , [ ] , $ options ) ; } | Sends the data to the given registration token notification key or topic via the GCM server . |
23,654 | public function configure ( array $ properties ) { foreach ( $ properties as $ name => $ value ) { $ methodName = 'set' . ucfirst ( strtolower ( $ name ) ) ; if ( method_exists ( $ this , $ methodName ) ) { $ this -> $ methodName ( $ value ) ; } } } | Associate given values to appropriate class properties . |
23,655 | public function validate ( $ value ) { $ assert = $ this -> getAssert ( ) ; if ( $ assert !== null ) { if ( is_callable ( $ assert ) ) { if ( ! call_user_func ( $ assert , $ value , $ this ) ) { throw new AssertException ( sprintf ( 'Custom validation fail with value (%s) "%s"' , gettype ( $ value ) , print_r ( $ value , true ) ) ) ; } } else { if ( $ value !== $ assert ) { throw new AssertException ( sprintf ( 'Failed asserting that actual value (%s) "%s" matches expected value (%s) "%s".' , gettype ( $ value ) , print_r ( $ value , true ) , gettype ( $ assert ) , print_r ( $ assert , true ) ) ) ; } } } return true ; } | Check that given value is valid . |
23,656 | protected function resolveProperty ( $ name ) { $ value = $ this -> $ name ; if ( is_callable ( $ value ) ) { return call_user_func ( $ value , $ this ) ; } return $ this -> resolveValue ( $ value ) ; } | Process set and return given property . |
23,657 | private function resolveValue ( $ value ) { if ( DataSet :: isPath ( $ value ) ) { if ( empty ( $ this -> dataSet ) ) { throw new ConfigurationException ( 'DataSet is required to resole value by path.' ) ; } $ value = $ this -> dataSet -> resolvePath ( $ value ) ; } if ( is_array ( $ value ) ) { foreach ( $ value as $ key => $ subValue ) { $ value [ $ key ] = $ this -> resolveValue ( $ subValue ) ; } } return $ value ; } | Find value in DataSet by given value if it is a path string . Otherwise given value will be returned . |
23,658 | private function bailIfConstructArguments ( string $ source , int $ width , int $ height ) : void { if ( $ width <= 0 ) { throw new InvalidArgumentException ( 'Width cannot be less or equal than zero.' ) ; } if ( $ height <= 0 ) { throw new InvalidArgumentException ( 'Height cannot be less or equal than zero.' ) ; } if ( ! file_exists ( $ source ) ) { throw new InvalidArgumentException ( 'Source file does not exists.' ) ; } } | Validate Arguments for Constructor |
23,659 | public static function buildFromHtml ( string $ html , Token $ parent = null , bool $ throwOnError = true ) { $ matchCriteria = array ( 'Php' => "/^\s*<\?(php)?\s/i" , 'Comment' => "/^\s*<!--/" , 'CData' => "/^\s*<!\[CDATA\[/" , 'DocType' => "/^\s*<!DOCTYPE /i" , 'Element' => "/^\s*<[a-z]/i" , 'Text' => "/^[^<]/" ) ; foreach ( $ matchCriteria as $ className => $ regex ) { if ( preg_match ( $ regex , $ html ) === 1 ) { $ fullClassName = "Kevintweber\\HtmlTokenizer\\Tokens\\" . $ className ; return new $ fullClassName ( $ parent , $ throwOnError ) ; } } if ( $ throwOnError ) { throw new TokenMatchingException ( ) ; } } | Factory method to build the correct token . |
23,660 | private function cloneStructure ( array & $ struct ) : void { foreach ( $ struct as & $ v ) { if ( is_object ( $ v ) ) { $ v = clone $ v ; } elseif ( is_array ( $ v ) ) { $ this -> cloneStructure ( $ v ) ; } } } | Clone all objects within the given array structure . |
23,661 | public function restore ( array $ settings = array ( ) ) { $ settings = array_values ( $ settings ) ; $ reflection = new ReflectionMethod ( get_class ( $ this ) , '__construct' ) ; $ alreadySet = $ reflection -> getNumberOfParameters ( ) ; $ index = 0 ; foreach ( $ this -> settings as & $ setting ) { if ( $ alreadySet > $ index ) { continue ; } if ( array_key_exists ( $ index , $ settings ) ) { $ setting = $ settings [ $ index ] === '' ? NULL : $ settings [ $ index ] ; } $ index ++ ; } } | Restore effect state from array |
23,662 | public function hex2rgb ( $ hex , $ returnString = FALSE ) { $ hex = str_replace ( '#' , '' , $ hex ) ; if ( strlen ( $ hex ) == 3 ) { $ r = hexdec ( substr ( $ hex , 0 , 1 ) . substr ( $ hex , 0 , 1 ) ) ; $ g = hexdec ( substr ( $ hex , 1 , 1 ) . substr ( $ hex , 1 , 1 ) ) ; $ b = hexdec ( substr ( $ hex , 2 , 1 ) . substr ( $ hex , 2 , 1 ) ) ; } else { $ r = hexdec ( substr ( $ hex , 0 , 2 ) ) ; $ g = hexdec ( substr ( $ hex , 2 , 2 ) ) ; $ b = hexdec ( substr ( $ hex , 4 , 2 ) ) ; } if ( $ returnString ) { return implode ( ', ' , array ( $ r , $ g , $ b ) ) ; } return array ( $ r , $ g , $ b ) ; } | Hexadecimal color to RGB conversion |
23,663 | public function setCart ( ShoppingCart $ cart ) { $ curr = $ this -> getOwner ( ) -> getCart ( ) ; $ contact = $ this -> getOwner ( ) -> Contact ( ) ; if ( isset ( $ curr ) && $ curr -> ID != $ cart -> ID ) { $ curr -> delete ( ) ; } $ cart -> CustomerID = $ contact -> ID ; return $ this ; } | Update the current cart . Also make sure no more than one is set at any one time . |
23,664 | private function renderButton ( ) { $ this -> params = Json :: encode ( [ 'btnName' => $ this -> options [ 'id' ] , 'cookieName' => $ this -> cookie [ 'name' ] , 'cookieValue' => addslashes ( $ this -> getHashedCookieValue ( $ this -> cookie [ 'value' ] ) ) , 'cookieOptions' => isset ( $ this -> cookie [ 'options' ] ) ? $ this -> cookie [ 'options' ] : null , ] ) ; if ( $ this -> cookie ( $ this -> cookie [ 'name' ] ) ) { Html :: addCssClass ( $ this -> options , 'active' ) ; } echo Button :: widget ( [ 'label' => $ this -> encodeLabel ? Html :: encode ( $ this -> label ) : $ this -> label , 'encodeLabel' => $ this -> encodeLabel , 'options' => ArrayHelper :: merge ( [ 'data-toggle' => 'button' ] , $ this -> options ) , ] ) ; } | Renders the toggle button . |
23,665 | private function renderButtonGroup ( ) { $ this -> params = Json :: encode ( [ 'btnName' => $ this -> options [ 'id' ] , 'cookieName' => $ this -> cookie [ 'name' ] , 'cookieValue' => addslashes ( $ this -> getHashedCookieValue ( $ this -> cookie [ 'value' ] ) ) , 'cookieOptions' => isset ( $ this -> cookie [ 'options' ] ) ? $ this -> cookie [ 'options' ] : null , 'toggleClass' => isset ( $ this -> toggleClass ) ? $ this -> toggleClass : null ] ) ; if ( $ this -> cookie ( $ this -> cookie [ 'name' ] ) ) { $ isActive = true ; } else { $ isActive = false ; } echo ButtonGroup :: widget ( [ 'id' => $ this -> options [ 'id' ] , 'buttons' => [ [ 'label' => $ this -> encodeLabel ? Html :: encode ( $ this -> label [ 0 ] ) : $ this -> label [ 0 ] , 'options' => [ 'class' => 'btn ' . ( $ isActive ? $ this -> toggleClass : 'btn-default' ) . ' ' . $ this -> options [ 'class' ] . ( $ isActive ? ' active' : '' ) ] ] , [ 'label' => $ this -> encodeLabel ? Html :: encode ( $ this -> label [ 1 ] ) : $ this -> label [ 1 ] , 'options' => [ 'class' => 'btn ' . ( $ isActive ? 'btn-default' : $ this -> toggleClass ) . ' ' . $ this -> options [ 'class' ] . ( $ isActive ? ' active' : '' ) ] ] , ] ] ) ; } | Renders the button group . |
23,666 | private function cookie ( $ name , $ value = null , $ expire = 0 , $ domain = '' , $ path = '/' , $ secure = false ) { if ( $ value === false ) { \ Yii :: $ app -> response -> cookies -> remove ( $ name ) ; } elseif ( $ value === null ) { return \ Yii :: $ app -> request -> cookies -> getValue ( $ name ) ; } } | Remove or return cookie value |
23,667 | private static function instantiate ( array $ declaration ) { $ fieldType = array_shift ( $ declaration ) ; $ class = "\\Zerg\\Field\\" . ucfirst ( strtolower ( $ fieldType ) ) ; if ( class_exists ( $ class ) ) { $ reflection = new \ ReflectionClass ( $ class ) ; return $ reflection -> newInstanceArgs ( $ declaration ) ; } throw new ConfigurationException ( "Field {$fieldType} doesn't exist" ) ; } | Create field instance by its declaration . |
23,668 | private function getApplicationNode ( ) : NodeDefinition { $ treeBuilder = new TreeBuilder ( 'application' ) ; return $ treeBuilder -> getRootNode ( ) -> addDefaultsIfNotSet ( ) -> children ( ) -> arrayNode ( 'version' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'file_path' ) -> info ( 'Path of a file who contains version of the application' ) -> defaultValue ( sprintf ( '%%kernel.project_dir%%/%s' , ApplicationService :: VERSION_FILE_NAME ) ) -> cannotBeEmpty ( ) -> end ( ) -> end ( ) -> end ( ) -> scalarNode ( 'name' ) -> info ( 'Name of application. May be displayed near logo.' ) -> defaultValue ( '' ) -> end ( ) -> scalarNode ( 'description' ) -> info ( 'Description of application. May be displayed near logo.' ) -> defaultValue ( '' ) -> end ( ) -> scalarNode ( 'empty_value_replacement' ) -> info ( 'Replacement of empty value. May be used to filter values in templates/views.' ) -> defaultValue ( '-' ) -> end ( ) -> end ( ) ; } | Returns the application node |
23,669 | private function getFormNode ( ) : NodeDefinition { $ treeBuilder = new TreeBuilder ( 'form' ) ; return $ treeBuilder -> getRootNode ( ) -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'novalidate' ) -> info ( 'Information if HTML5 inline validation is disabled' ) -> defaultFalse ( ) -> end ( ) -> end ( ) ; } | Returns the form node |
23,670 | private function getDateNode ( ) : NodeDefinition { $ treeBuilder = new TreeBuilder ( 'date' ) ; return $ treeBuilder -> getRootNode ( ) -> addDefaultsIfNotSet ( ) -> children ( ) -> arrayNode ( 'format' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( DateLength :: DATE ) -> info ( 'Format of date without time' ) -> defaultValue ( 'd.m.Y' ) -> end ( ) -> scalarNode ( DateLength :: DATETIME ) -> info ( 'Format of date with time' ) -> defaultValue ( 'd.m.Y H:i' ) -> end ( ) -> scalarNode ( DateLength :: TIME ) -> info ( 'Format of time without date' ) -> defaultValue ( 'H:i' ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) ; } | Returns the date node |
23,671 | public static function empty ( ... $ values ) : bool { self :: handleInvalidArguments ( $ values ) ; foreach ( $ values as $ value ) { if ( empty ( $ value ) === false ) { return false ; } } return true ; } | Checks if specified values are empty |
23,672 | public static function typeOf ( $ types , ... $ values ) : bool { if ( is_string ( $ types ) ) { $ types = [ $ types ] ; } if ( is_array ( $ types ) === false ) { throw new InvalidArgumentException ( sprintf ( static :: MSG_TYPE_MISMATCH , gettype ( $ types ) ) ) ; } foreach ( $ values as $ value ) { $ isObject = is_object ( $ value ) ; $ match = false ; $ valueType = gettype ( $ value ) ; foreach ( $ types as $ type ) { if ( ( $ isObject && $ value instanceof $ type ) xor ( $ isObject === false && $ valueType === $ type ) ) { $ match = true ; break ; } } if ( $ match === false ) { if ( $ isObject ) { $ message = 'Expected value to be an instance of %s, instance of %s given!' ; $ valueType = get_class ( $ value ) ; } else { $ message = 'Expected value to be of type %s, %s given!' ; } throw new TypeError ( sprintf ( $ message , implode ( ' or ' , $ types ) , $ valueType ) ) ; } } return true ; } | Checks if values are of specified types or instances |
23,673 | public static function unregisterHelper ( $ name ) { Argument :: i ( ) -> test ( 1 , 'string' ) ; if ( isset ( self :: $ helpers [ $ name ] ) ) { unset ( self :: $ helpers [ $ name ] ) ; } } | The opposite of registerHelper |
23,674 | public static function unregisterPartial ( $ name ) { Argument :: i ( ) -> test ( 1 , 'string' ) ; if ( isset ( self :: $ partials [ $ name ] ) ) { unset ( self :: $ partials [ $ name ] ) ; } } | The opposite of registerPartial |
23,675 | private function addItem ( ) { $ args = func_get_args ( ) ; $ this -> items [ $ args [ 0 ] ] = implode ( ':' , array_slice ( $ args , 1 ) ) ; return $ this ; } | Adds a new property item . |
23,676 | private function render ( ) { $ parts = [ ] ; if ( ! empty ( $ this -> items ) ) { $ parts [ ] = implode ( ',' , $ this -> items ) ; } $ parts [ ] = isset ( $ this -> items [ 'base64' ] ) ? self :: base64Encode ( $ this -> text ) : urlencode ( $ this -> text ) ; return implode ( ':' , $ parts ) ; } | Renders the text URL string . |
23,677 | public function index ( $ params = [ ] , $ optParams = [ ] ) { if ( $ optParams instanceof IndexParams ) { $ optParams = $ optParams -> toArray ( true ) ; } return $ this -> sendRequest ( [ ] , [ 'restAction' => 'index' , 'params' => $ params , 'getParams' => $ optParams , ] , function ( $ response ) { $ firewalls = [ ] ; foreach ( $ response -> data [ 'items' ] as $ firewall ) { $ firewalls [ ] = new Firewall ( $ firewall ) ; } return new Index ( [ 'models' => $ firewalls , 'totalCount' => ( int ) $ response -> data [ 'totalCount' ] , 'nextPageToken' => $ response -> data [ 'nextPageToken' ] , ] ) ; } ) ; } | Fetches all firewalls . |
23,678 | public function create ( $ params , $ optParams = [ ] ) { if ( ! $ params instanceof Firewall ) { throw new InvalidParamException ( Firewall :: class . ' is required!' ) ; } return $ this -> sendRequest ( [ ] , [ 'restAction' => 'create' , 'postParams' => $ params -> toArray ( ) , 'getParams' => $ optParams , ] , function ( $ response ) { return isset ( $ response -> data ) ? new Firewall ( $ response -> data ) : $ response ; } ) ; } | Creates a firewall . |
23,679 | public function view ( $ params , $ optParams = [ ] ) { if ( $ params instanceof Firewall ) { $ params = $ params -> id ; } return $ this -> sendRequest ( [ ] , [ 'restAction' => 'view' , 'restId' => $ params , 'getParams' => $ optParams , ] , function ( $ response ) { return isset ( $ response -> data ) ? new Firewall ( $ response -> data ) : $ response ; } ) ; } | Fetches a firewall . |
23,680 | public function mergeWith ( Address $ address ) : self { return new static ( ... \ array_merge ( $ this -> ipv4 , $ address -> ipv4 ) , ... \ array_merge ( $ this -> ipv6 , $ address -> ipv6 ) ) ; } | Merge IP address with addresses from the given address . |
23,681 | public function health ( ) { $ healths = [ ] ; foreach ( $ this -> indicators as $ key => $ indicator ) { $ healths [ $ key ] = $ indicator -> health ( ) ; } return $ this -> healthAggregator -> aggregate ( $ healths ) ; } | Return an indication of health . |
23,682 | public function purge ( $ dir ) { if ( ! is_dir ( $ dir ) ) { return ; } $ files = scandir ( $ dir ) ; if ( $ files !== false ) { foreach ( $ files as $ file ) { if ( $ file === '.' || $ file === '..' ) { continue ; } $ path = $ dir . '/' . $ file ; if ( is_dir ( $ path ) ) { $ this -> purge ( $ path ) ; rmdir ( $ path ) ; } else { unlink ( $ path ) ; } } } } | Delete all files inside a directory . |
23,683 | public function copy ( $ src , $ dest ) { if ( is_dir ( $ src ) ) { $ this -> ensureDir ( $ dest ) ; $ files = scandir ( $ src ) ; foreach ( $ files as $ file ) { if ( $ file !== '.' && $ file !== '..' ) { $ this -> copy ( $ src . '/' . $ file , $ dest . '/' . $ file ) ; } } } else { $ this -> ensureDir ( dirname ( $ dest ) ) ; copy ( $ src , $ dest ) ; } } | Copy file and create directory if not exists . |
23,684 | public static function configMerge ( ) { $ result = array ( ) ; $ args = func_get_args ( ) ; foreach ( $ args as $ arg ) { if ( ! is_array ( $ arg ) ) { continue ; } foreach ( $ arg as $ key => $ value ) { if ( is_numeric ( $ key ) ) { $ result [ ] = $ value ; } elseif ( array_key_exists ( $ key , $ result ) && is_array ( $ result [ $ key ] ) && is_array ( $ value ) ) { $ result [ $ key ] = ConfigServiceProvider :: configMerge ( $ result [ $ key ] , $ value ) ; } else { $ result [ $ key ] = $ value ; } } } return $ result ; } | Like array_merge_recursive but good |
23,685 | public function completed ( UserInterface $ user ) { $ queryBuilder = $ this -> createQueryBuilder ( 'a' ) ; $ queryBuilder -> where ( 'a.user = :user' ) -> andWhere ( 'a.completed = :completed' ) ; $ queryBuilder -> setParameters ( [ 'user' => $ user , 'completed' => true ] ) ; try { return $ queryBuilder -> getQuery ( ) -> getSingleResult ( ) ; } catch ( NoResultException $ e ) { return false ; } } | Checks if a valid activation has been completed . |
23,686 | public function submit ( Context $ context , $ work , int $ priority = 0 ) : Promise { $ job = new class ( $ context ) extends Placeholder { public $ priority ; public $ generator ; } ; $ job -> priority = $ priority ; $ job -> generator = ( $ work instanceof \ Generator ) ? $ work : Coroutine :: generate ( $ work , $ context ) ; for ( $ inserted = null , $ count = \ count ( $ this -> jobs ) , $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( $ priority <= $ this -> jobs [ $ i ] -> priority ) { $ inserted = \ array_splice ( $ this -> jobs , $ i , 0 , [ $ job ] ) ; break ; } } if ( $ inserted === null ) { $ this -> jobs [ ] = $ job ; } if ( $ this -> running < $ this -> concurrency ) { $ this -> running ++ ; $ context -> getLoop ( ) -> defer ( \ Closure :: fromCallable ( [ $ this , 'executeNextJob' ] ) ) ; } return $ context -> keepBusy ( $ job -> promise ( ) ) ; } | Submit a job to the executor . |
23,687 | protected function executeNextJob ( ) : void { while ( $ this -> jobs ) { $ job = \ array_pop ( $ this -> jobs ) ; if ( $ job -> state & AbstractPromise :: PENDING ) { $ done = false ; ( new Coroutine ( $ job -> context , $ job -> generator ) ) -> when ( function ( ? \ Throwable $ e , $ v = null ) use ( $ job , & $ done ) { if ( $ e ) { $ job -> fail ( $ e ) ; } else { $ job -> resolve ( $ v ) ; } if ( $ done ) { $ this -> executeNextJob ( ) ; } else { $ done = true ; } } ) ; if ( ! $ done ) { $ done = true ; return ; } } } $ this -> running -- ; } | Execute the queued job with the highest priority . |
23,688 | public function setFeature ( ChildFeature $ v = null ) { if ( $ v === null ) { $ this -> setFeatureId ( NULL ) ; } else { $ this -> setFeatureId ( $ v -> getId ( ) ) ; } $ this -> aFeature = $ v ; if ( $ v !== null ) { $ v -> addFeatureFeatureType ( $ this ) ; } return $ this ; } | Declares an association between this object and a ChildFeature object . |
23,689 | public function getFeature ( ConnectionInterface $ con = null ) { if ( $ this -> aFeature === null && ( $ this -> feature_id !== null ) ) { $ this -> aFeature = FeatureQuery :: create ( ) -> findPk ( $ this -> feature_id , $ con ) ; } return $ this -> aFeature ; } | Get the associated ChildFeature object |
23,690 | public function initFeatureTypeAvMetas ( $ overrideExisting = true ) { if ( null !== $ this -> collFeatureTypeAvMetas && ! $ overrideExisting ) { return ; } $ this -> collFeatureTypeAvMetas = new ObjectCollection ( ) ; $ this -> collFeatureTypeAvMetas -> setModel ( '\FeatureType\Model\FeatureTypeAvMeta' ) ; } | Initializes the collFeatureTypeAvMetas collection . |
23,691 | public function getFeatureTypeAvMetas ( $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collFeatureTypeAvMetasPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collFeatureTypeAvMetas || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collFeatureTypeAvMetas ) { $ this -> initFeatureTypeAvMetas ( ) ; } else { $ collFeatureTypeAvMetas = ChildFeatureTypeAvMetaQuery :: create ( null , $ criteria ) -> filterByFeatureFeatureType ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collFeatureTypeAvMetasPartial && count ( $ collFeatureTypeAvMetas ) ) { $ this -> initFeatureTypeAvMetas ( false ) ; foreach ( $ collFeatureTypeAvMetas as $ obj ) { if ( false == $ this -> collFeatureTypeAvMetas -> contains ( $ obj ) ) { $ this -> collFeatureTypeAvMetas -> append ( $ obj ) ; } } $ this -> collFeatureTypeAvMetasPartial = true ; } reset ( $ collFeatureTypeAvMetas ) ; return $ collFeatureTypeAvMetas ; } if ( $ partial && $ this -> collFeatureTypeAvMetas ) { foreach ( $ this -> collFeatureTypeAvMetas as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collFeatureTypeAvMetas [ ] = $ obj ; } } } $ this -> collFeatureTypeAvMetas = $ collFeatureTypeAvMetas ; $ this -> collFeatureTypeAvMetasPartial = false ; } } return $ this -> collFeatureTypeAvMetas ; } | Gets an array of ChildFeatureTypeAvMeta objects which contain a foreign key that references this object . |
23,692 | public function countFeatureTypeAvMetas ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collFeatureTypeAvMetasPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collFeatureTypeAvMetas || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collFeatureTypeAvMetas ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getFeatureTypeAvMetas ( ) ) ; } $ query = ChildFeatureTypeAvMetaQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByFeatureFeatureType ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collFeatureTypeAvMetas ) ; } | Returns the number of related FeatureTypeAvMeta objects . |
23,693 | public function addFeatureTypeAvMeta ( ChildFeatureTypeAvMeta $ l ) { if ( $ this -> collFeatureTypeAvMetas === null ) { $ this -> initFeatureTypeAvMetas ( ) ; $ this -> collFeatureTypeAvMetasPartial = true ; } if ( ! in_array ( $ l , $ this -> collFeatureTypeAvMetas -> getArrayCopy ( ) , true ) ) { $ this -> doAddFeatureTypeAvMeta ( $ l ) ; } return $ this ; } | Method called to associate a ChildFeatureTypeAvMeta object to this object through the ChildFeatureTypeAvMeta foreign key attribute . |
23,694 | public function getFeatureTypeAvMetasJoinFeatureAv ( $ criteria = null , $ con = null , $ joinBehavior = Criteria :: LEFT_JOIN ) { $ query = ChildFeatureTypeAvMetaQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'FeatureAv' , $ joinBehavior ) ; return $ this -> getFeatureTypeAvMetas ( $ query , $ con ) ; } | If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this FeatureFeatureType is new it will return an empty collection ; or if this FeatureFeatureType has previously been saved it will retrieve related FeatureTypeAvMetas from storage . |
23,695 | function Put ( $ key , $ value ) { if ( ! $ this -> fd || $ this -> mode != 'w' ) { trigger_error ( "XDB::Put(), null db handler or readonly." , E_USER_WARNING ) ; return false ; } $ klen = strlen ( $ key ) ; $ vlen = strlen ( $ value ) ; if ( ! $ klen || $ klen > XDB_MAXKLEN ) return false ; $ rec = $ this -> _get_record ( $ key ) ; if ( isset ( $ rec [ 'vlen' ] ) && ( $ vlen <= $ rec [ 'vlen' ] ) ) { if ( $ vlen > 0 ) { fseek ( $ this -> fd , $ rec [ 'voff' ] , SEEK_SET ) ; fwrite ( $ this -> fd , $ value , $ vlen ) ; } if ( $ vlen < $ rec [ 'vlen' ] ) { $ newlen = $ rec [ 'len' ] + $ vlen - $ rec [ 'vlen' ] ; $ newbuf = pack ( 'I' , $ newlen ) ; fseek ( $ this -> fd , $ rec [ 'poff' ] + 4 , SEEK_SET ) ; fwrite ( $ this -> fd , $ newbuf , 4 ) ; } return true ; } $ new = array ( 'loff' => 0 , 'llen' => 0 , 'roff' => 0 , 'rlen' => 0 ) ; if ( isset ( $ rec [ 'vlen' ] ) ) { $ new [ 'loff' ] = $ rec [ 'loff' ] ; $ new [ 'llen' ] = $ rec [ 'llen' ] ; $ new [ 'roff' ] = $ rec [ 'roff' ] ; $ new [ 'rlen' ] = $ rec [ 'rlen' ] ; } $ buf = pack ( 'IIIIC' , $ new [ 'loff' ] , $ new [ 'llen' ] , $ new [ 'roff' ] , $ new [ 'rlen' ] , $ klen ) ; $ buf .= $ key . $ value ; $ len = $ klen + $ vlen + 17 ; $ off = $ this -> fsize ; fseek ( $ this -> fd , $ off , SEEK_SET ) ; fwrite ( $ this -> fd , $ buf , $ len ) ; $ this -> fsize += $ len ; $ pbuf = pack ( 'II' , $ off , $ len ) ; fseek ( $ this -> fd , $ rec [ 'poff' ] , SEEK_SET ) ; fwrite ( $ this -> fd , $ pbuf , 8 ) ; return true ; } | Insert Or Update the value |
23,696 | function Draw ( $ i = - 1 ) { if ( $ i < 0 || $ i >= $ this -> hash_prime ) { $ i = 0 ; $ j = $ this -> hash_prime ; } else { $ j = $ i + 1 ; } echo "Draw the XDB data [$i ~ $j]. (" . trim ( $ this -> Version ( ) ) . ")\n\n" ; while ( $ i < $ j ) { $ poff = $ i * 8 + 32 ; fseek ( $ this -> fd , $ poff , SEEK_SET ) ; $ buf = fread ( $ this -> fd , 8 ) ; if ( strlen ( $ buf ) != 8 ) break ; $ ptr = unpack ( 'Ioff/Ilen' , $ buf ) ; $ this -> _cur_depth = 0 ; $ this -> _node_num = 0 ; $ this -> _draw_node ( $ ptr [ 'off' ] , $ ptr [ 'len' ] ) ; echo "-------------------------------------------\n" ; echo "Tree(xdb) [$i] max_depth: {$this->_cur_depth} nodes_num: {$this->_node_num}\n" ; $ i ++ ; } } | Traversal every tree ... & debug to test |
23,697 | function Version ( ) { $ ver = ( is_null ( $ this ) ? XDB_VERSION : $ this -> version ) ; $ str = sprintf ( "%s/%d.%d" , XDB_TAGNAME , ( $ ver >> 5 ) , ( $ ver & 0x1f ) ) ; if ( ! is_null ( $ this ) ) $ str .= " <base={$this->hash_base}, prime={$this->hash_prime}>" ; return $ str ; } | Show the version |
23,698 | function Close ( ) { if ( ! $ this -> fd ) return ; if ( $ this -> mode == 'w' ) { $ buf = pack ( 'I' , $ this -> fsize ) ; fseek ( $ this -> fd , 12 , SEEK_SET ) ; fwrite ( $ this -> fd , $ buf , 4 ) ; flock ( $ this -> fd , LOCK_UN ) ; } fclose ( $ this -> fd ) ; $ this -> fd = false ; } | Close the DB |
23,699 | function Optimize ( $ i = - 1 ) { if ( ! $ this -> fd || $ this -> mode != 'w' ) { trigger_error ( "XDB::Optimize(), null db handler or readonly." , E_USER_WARNING ) ; return false ; } if ( $ i < 0 || $ i >= $ this -> hash_prime ) { $ i = 0 ; $ j = $ this -> hash_prime ; } else { $ j = $ i + 1 ; } while ( $ i < $ j ) { $ this -> _optimize_index ( $ i ) ; $ i ++ ; } } | Optimize the tree |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.