idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
4,400 | public function setHttpClient ( HttpClient $ client ) { $ this -> httpClient = $ client ; $ this -> httpClient -> setDefaultOption ( 'headers/Authorization' , $ this -> getAuthorizationHeader ( ) ) ; $ this -> httpClient -> setDefaultOption ( 'headers/Accepts' , 'application/json' ) ; $ this -> bootModules ( ) ; } | Replace the internal http client |
4,401 | protected function bootModules ( ) { $ this -> container = new ContainerModule ( ) ; $ this -> service = new ServiceModule ( ) ; $ this -> container -> setHttpClient ( $ this -> httpClient ) ; $ this -> service -> setHttpClient ( $ this -> httpClient ) ; } | Boot all client modules |
4,402 | public function setBearerKey ( $ bearerKey ) { $ this -> bearerKey = $ bearerKey ; $ this -> httpClient -> setDefaultOption ( 'headers/Authorization' , $ this -> getAuthorizationHeader ( ) ) ; } | Set the bearer key |
4,403 | function doImage ( ) { if ( $ this -> use_transparent_text == true || $ this -> bgimg != "" ) { $ this -> im = imagecreatetruecolor ( $ this -> image_width , $ this -> image_height ) ; $ bgcolor = imagecolorallocate ( $ this -> im , hexdec ( substr ( $ this -> image_bg_color , 1 , 2 ) ) , hexdec ( substr ( $ this -> im... | Generate and output the image |
4,404 | function setBackground ( ) { $ dat = @ getimagesize ( $ this -> bgimg ) ; if ( $ dat == false ) { return ; } switch ( $ dat [ 2 ] ) { case 1 : $ newim = @ imagecreatefromgif ( $ this -> bgimg ) ; break ; case 2 : $ newim = @ imagecreatefromjpeg ( $ this -> bgimg ) ; break ; case 3 : $ newim = @ imagecreatefrompng ( $ t... | Set the background of the CAPTCHA image |
4,405 | function arcLines ( ) { $ colors = explode ( ',' , $ this -> arc_line_colors ) ; imagesetthickness ( $ this -> im , 3 ) ; $ color = $ colors [ rand ( 0 , sizeof ( $ colors ) - 1 ) ] ; $ linecolor = imagecolorallocate ( $ this -> im , hexdec ( substr ( $ color , 1 , 2 ) ) , hexdec ( substr ( $ color , 3 , 2 ) ) , hexdec... | Draw arced lines over the text |
4,406 | function drawLines ( ) { $ linecolor = imagecolorallocate ( $ this -> im , hexdec ( substr ( $ this -> line_color , 1 , 2 ) ) , hexdec ( substr ( $ this -> line_color , 3 , 2 ) ) , hexdec ( substr ( $ this -> line_color , 5 , 2 ) ) ) ; imagesetthickness ( $ this -> im , $ this -> line_thickness ) ; for ( $ x = 1 ; $ x ... | Draw lines on the image |
4,407 | function createCode ( ) { $ this -> code = false ; if ( $ this -> use_wordlist && is_readable ( $ this -> wordlist_file ) ) { $ this -> code = $ this -> readCodeFromFile ( ) ; } if ( $ this -> code == false ) { $ this -> code = $ this -> generateCode ( $ this -> code_length ) ; } $ this -> saveData ( ) ; } | Create a code and save to the session |
4,408 | function generateCode ( $ len ) { $ code = '' ; for ( $ i = 1 , $ cslen = strlen ( $ this -> charset ) ; $ i <= $ len ; ++ $ i ) { $ code .= strtoupper ( $ this -> charset { rand ( 0 , $ cslen - 1 ) } ) ; } return $ code ; } | Generate a code |
4,409 | function readCodeFromFile ( ) { $ fp = @ fopen ( $ this -> wordlist_file , 'rb' ) ; if ( ! $ fp ) return false ; $ fsize = filesize ( $ this -> wordlist_file ) ; if ( $ fsize < 32 ) return false ; if ( $ fsize < 128 ) { $ max = $ fsize ; } else { $ max = 128 ; } fseek ( $ fp , rand ( 0 , $ fsize - $ max ) , SEEK_SET ) ... | Reads a word list file to get a code |
4,410 | function output ( ) { header ( "Expires: Sun, 1 Jan 2000 12:00:00 GMT" ) ; header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s" ) . "GMT" ) ; header ( "Cache-Control: no-store, no-cache, must-revalidate" ) ; header ( "Cache-Control: post-check=0, pre-check=0" , false ) ; header ( "Pragma: no-cache" ) ; switch ( $ thi... | Output image to the browser |
4,411 | function validate ( ) { if ( isset ( $ _SESSION [ 'securimage_code_value' ] ) && ! empty ( $ _SESSION [ 'securimage_code_value' ] ) ) { if ( $ _SESSION [ 'securimage_code_value' ] == strtolower ( trim ( $ this -> code_entered ) ) ) { $ this -> correct_code = true ; $ _SESSION [ 'securimage_code_value' ] = '' ; } else {... | Validate the code to the user code |
4,412 | protected function addFuncGetArgs ( array $ nodes , array $ params , Param $ vParam ) { $ newNodes = [ ] ; $ newNodes [ ] = new Expr \ Assign ( new Expr \ Variable ( $ vParam -> name ) , new Expr \ FuncCall ( new Name ( 'func_get_args' ) ) ) ; foreach ( $ params as $ param ) { $ newNodes [ ] = new Expr \ Assign ( new E... | Construct a func_get_args compatible version of a variadic function . |
4,413 | public static function decompilePath ( $ path ) { if ( is_object ( $ path ) && ! method_exists ( $ path , '__toString' ) ) { throw InvalidArgumentException :: create ( 'scalar' , $ path ) ; } $ path = ( string ) $ path ; if ( preg_match ( '/^[a-z0-9_]*\./i' , $ path ) ) { return explode ( '.' , $ path ) ; } else { $ pa... | Decompiles an array path string into an array of the path elements . |
4,414 | public static function get ( $ arrayPath , array $ array , $ default = null ) { $ pathKeys = self :: decompilePath ( $ arrayPath ) ; $ _a = $ array ; foreach ( $ pathKeys as $ key ) { if ( ! isset ( $ _a [ $ key ] ) ) { return $ default ; } else { $ _a = $ _a [ $ key ] ; } } return $ _a ; } | Return a value from an array using an array path . |
4,415 | public static function view ( $ fileName ) { $ array = explode ( "/" , $ fileName ) ; if ( count ( $ array ) == 1 ) $ array = explode ( '.' , $ fileName ) ; return Registry :: getConfig ( ) [ 'root' ] . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . join ( DIRECTORY_SEPARATO... | This method defines the path to views folder |
4,416 | public static function inProperty ( string $ name , Deserializes $ deserializer ) : ExposesDataKey { return new self ( $ name , $ name , $ deserializer ) ; } | Creates a new nested has - one mapping . |
4,417 | public static function inPropertyWithDifferentKey ( string $ name , string $ key , Deserializes $ deserializer ) : ExposesDataKey { return new self ( $ name , $ key , $ deserializer ) ; } | Creates a new nested has - one mapping using the data from a specific key . |
4,418 | public function attachPayload ( $ key , $ value ) { if ( is_null ( $ this -> payload ) ) { $ this -> payload = [ ] ; } $ this -> payload [ $ key ] = $ value ; return $ this ; } | Set payload data . |
4,419 | public function getPayloadData ( $ key , $ default = null ) { if ( is_null ( $ this -> payload ) ) { return null ; } return $ this -> payload [ $ key ] ?? $ default ; } | Return payload data . |
4,420 | public function hasPayloadData ( $ keys ) : bool { if ( is_null ( $ this -> payload ) ) { return false ; } if ( ! is_array ( $ keys ) ) { $ keys = [ $ keys ] ; } foreach ( $ keys as $ key ) { if ( ! isset ( $ this -> payload [ $ key ] ) ) { return false ; } } return true ; } | Determines if payload has requried keys . |
4,421 | public function on ( $ resource ) { if ( ! $ this -> runnable ( ) ) { throw new \ InvalidArgumentException ( 'Command execution is restricted.' ) ; } if ( is_array ( $ resource ) ) { return $ this -> executeOnMulitpleResources ( $ resource ) ; } return $ this -> executeOn ( $ resource ) ; } | Execute command on single or multiple resources . |
4,422 | protected function executeOn ( ApiResourceInterface $ resource ) { $ response = $ this -> execute ( $ resource ) ; if ( method_exists ( $ this , 'handleResponse' ) ) { return $ this -> handleResponse ( $ response , $ resource ) ; } return true ; } | Execute current command on given resource . |
4,423 | protected function executeOnMulitpleResources ( array $ resources ) : array { $ results = [ ] ; foreach ( $ resources as $ resource ) { $ results [ $ resource -> name ( ) ] = $ this -> executeOn ( $ resource ) ; } return $ results ; } | Execute current command on multiple resources . |
4,424 | protected function execute ( ApiResourceInterface $ resource ) { $ client = $ resource -> getHttpClient ( ) ; if ( is_null ( $ options = $ this -> requestOptions ( ) ) ) { return $ client -> request ( $ this -> requestMethod ( ) , $ this -> requestUrl ( $ resource ) ) ; } return $ client -> request ( $ this -> requestM... | Execute current command . |
4,425 | public static function soft_delete_property ( $ key , $ default = null ) { $ class = get_called_class ( ) ; if ( ! array_key_exists ( $ class , static :: $ _soft_delete_cached ) ) { static :: soft_delete_properties ( ) ; } return \ Arr :: get ( static :: $ _soft_delete_cached [ $ class ] , $ key , $ default ) ; } | Fetches a soft delete property description array or specific data from it . Stolen from parent class . |
4,426 | public function purge ( $ cascade = null , $ use_transaction = false ) { $ this -> _disable_soft_delete = true ; $ result = parent :: delete ( $ cascade , $ use_transaction ) ; $ this -> _disable_soft_delete = false ; return $ result ; } | Permanently deletes records using the parent Model delete function |
4,427 | protected function should_cascade_delete ( $ rel ) { if ( ! is_subclass_of ( $ rel -> model_to , 'Orm\Model_Soft' ) && ! is_subclass_of ( $ rel -> model_to , 'Orm\Model_Temporal' ) ) { throw new RelationNotSoft ( 'Both sides of the relation must be subclasses of Model_Soft or Model_Temporal if cascade delete is true. '... | Returns true unless the related model is not soft or temporal |
4,428 | public function restore ( $ cascade_restore = null ) { $ deleted_column = static :: soft_delete_property ( 'deleted_field' , static :: $ _default_field_name ) ; $ this -> { $ deleted_column } = null ; $ this -> freeze ( ) ; foreach ( $ this -> relations ( ) as $ rel_name => $ rel ) { $ rel_cascade = is_null ( $ cascade... | Allows a soft deleted entry to be restored . |
4,429 | public static function query ( $ options = array ( ) ) { $ query = Query_Soft :: forge ( get_called_class ( ) , static :: connection ( ) , $ options ) ; if ( static :: get_filter_status ( ) ) { $ query -> set_soft_filter ( static :: soft_delete_property ( 'deleted_field' , static :: $ _default_field_name ) ) ; } return... | Overrides the query method to allow soft delete items to be filtered out . |
4,430 | public static function getCoordinatesWithinRadius ( array $ coordinates , array $ center , $ radius ) : array { $ resultArray = [ ] ; foreach ( $ coordinates as $ key => $ coordinate ) { if ( self :: isCoordinatesInRadius ( $ coordinate , $ center , $ radius ) ) { $ resultArray [ $ key ] = $ coordinate ; } } return $ r... | Return array of coordinates within some radius |
4,431 | public static function isCoordinatesInRadius ( array $ coordinates , array $ center , $ radius ) : bool { list ( $ lat1 , $ long1 ) = $ center ; list ( $ lat2 , $ long2 ) = $ coordinates ; $ distance = 3959 * acos ( cos ( self :: radians ( $ lat1 ) ) * cos ( self :: radians ( $ lat2 ) ) * cos ( self :: radians ( $ long... | Check if coordinates is nearby center in radius |
4,432 | public function createNewCustomFilter ( $ filterName , $ routeName , $ routeParameters , $ filterParameters , $ user = null ) { $ newFilter = new CustomFilter ( ) ; $ newFilter -> setName ( $ filterName ) -> setRouteName ( $ routeName ) -> setRouteParameters ( json_encode ( $ routeParameters , JSON_UNESCAPED_SLASHES ) ... | Create and persists a new CustomFilter . |
4,433 | public function setTarget ( $ target ) { if ( ! file_exists ( dirname ( $ target ) ) ) { throw new Exception \ InvalidArgumentException ( "The directory '$target' does not exist" ) ; } $ target = str_replace ( [ '/' , '\\' ] , DIRECTORY_SEPARATOR , ( string ) $ target ) ; $ this -> options [ 'target' ] = $ target ; ret... | Sets the target to use |
4,434 | public function errorString ( $ error ) { switch ( $ error ) { case ZipArchive :: ER_MULTIDISK : return 'Multidisk ZIP Archives not supported' ; case ZipArchive :: ER_RENAME : return 'Failed to rename the temporary file for ZIP' ; case ZipArchive :: ER_CLOSE : return 'Failed to close the ZIP Archive' ; case ZipArchive ... | Returns the proper string based on the given error constant |
4,435 | public function isSelected ( ) { if ( Navigation :: clearQueryArg ( Request :: getArgumentValue ( 'q' ) ) == Navigation :: clearQueryArg ( $ this -> urlCode ) ) { return true ; } return false ; } | Check if the breadcrumb item match the current page |
4,436 | public function __async_getchild ( $ structureId ) { $ structure = null ; if ( dbQuery ( Navigation :: class ) -> cond ( 'StructureID' , $ structureId ) -> first ( $ structure ) ) { $ tree = new SamsonTree ( 'tree/template' , 0 , 'product/addchildren' ) ; return array ( 'status' => 1 , 'tree' => $ tree -> htmlTree ( $ ... | Function to retrieve tree structure |
4,437 | protected function findRegion ( ) { if ( $ this -> locale ) { $ currentLang = $ this -> getLanguageFromLocale ( $ this -> locale ) ; $ defaultLang = $ this -> getLanguageFromLocale ( static :: $ default ) ; if ( $ currentLang == $ defaultLang ) { $ region = $ this -> getRegionFromLocale ( static :: $ default ) ; if ( $... | Find the region for the current language |
4,438 | public function getRegion ( ) { $ region = $ this -> getRegionFromLocale ( $ this -> getLocale ( ) ) ; if ( ! $ region ) { $ region = $ this -> findRegion ( ) ; } return $ region ; } | Returns the region code |
4,439 | public function toUriString ( Scheme $ scheme = null ) { $ authority_string = $ this -> user_info -> toUriString ( ) . $ this -> host -> toUriString ( ) . $ this -> port -> toUriString ( $ scheme ) ; if ( ! empty ( $ authority_string ) ) { $ authority_string = "//" . $ authority_string ; } return $ authority_string ; } | Returns a string representation of the authority formatted so that it can be compiled into a complete URI string per the Uri object s string specification . |
4,440 | protected static function compileValidPattern ( ) { $ user_info_pattern = UserInfo :: getValidPattern ( ) ; $ host_pattern = Host :: getValidPattern ( ) ; $ port_pattern = Port :: getValidPattern ( ) ; $ reg_start = '/^$|^' ; $ reg_end = '$/' ; self :: $ part_pattern = '((?\'user_info\'' . $ user_info_pattern . ')@)?' ... | Compiles a valid pattern for an authority based upon valid patterns for user info host and port . |
4,441 | protected function explodeAuthority ( $ authority ) { $ reg_start = '/^' ; $ user_info_part = '(?:(?\'user_info\'.+)@)?' ; $ host_part = '(?\'host\'\[.+\]|.[^:]+)' ; $ port_part = '(?::(?\'port\'[0-9]+))?' ; $ reg_end = '/' ; $ authority_syntax = $ reg_start . $ user_info_part . $ host_part . $ port_part . $ reg_end ; ... | Splits URI authority data into user info host and port data returning an array with named keys . |
4,442 | public static function convertPackageVersion ( PackageInterface $ package , $ fullReference = false ) { $ version = $ package -> getPrettyVersion ( ) ; if ( 'dev' === $ package -> getStability ( ) ) { if ( null === ( $ reference = $ package -> getDistReference ( ) ) ) { if ( null === ( $ reference = $ package -> getSou... | Convert a package version into string representation . |
4,443 | public function convertPackageToArray ( PackageInterface $ package , PackageInterface $ upgrade = null ) { $ name = $ package -> getPrettyName ( ) ; $ data = new JsonArray ( [ 'name' => $ name , 'version' => $ this -> convertPackageVersion ( $ package ) , 'constraint' => $ this -> getConstraint ( $ name ) , 'type' => $... | Convert a package to array information used by json API . |
4,444 | public function convertRepositoryToArray ( RepositoryInterface $ repository , $ requiredOnly = false , RepositoryInterface $ upgradeList = null ) { $ requires = $ requiredOnly ? $ this -> rootPackage -> getRequires ( ) : false ; $ packages = new JsonArray ( ) ; foreach ( $ repository -> getPackages ( ) as $ package ) {... | Convert the information of all packages in a repository to an array used by json API . |
4,445 | private function convertCompletePackage ( CompletePackageInterface $ package , $ data ) { $ data -> set ( 'description' , $ package -> getDescription ( ) ) ; $ data -> set ( 'license' , $ package -> getLicense ( ) ) ; if ( $ keywords = $ package -> getKeywords ( ) ) { $ data -> set ( 'keywords' , $ keywords ) ; } if ( ... | Convert the data of a complete package to the passed json array . |
4,446 | public function upload ( $ sourceFile , $ destinationFile ) { $ destination = $ this -> storagePath . rtrim ( $ destinationFile , '/' ) ; Service :: $ log -> msg ( 'Filesystem: Copying file to the backup storage location: ' . $ sourceFile ) ; copy ( $ sourceFile , $ destination ) ; Service :: $ log -> msg ( 'Filesystem... | Store the give backup |
4,447 | public function moveOldBackup ( ) { Service :: $ log -> msg ( 'Filesystem: moving old backups' ) ; if ( file_exists ( $ this -> storagePath . 'backup-2days-old' ) ) { unlink ( $ this -> storagePath . 'backup-2days-old' ) ; } $ sourceFile = $ this -> storagePath . 'backup-1day-old' ; $ destinationFile = $ this -> storag... | Moves around the current backups on the filesystem and does some cleanup before new backups are created . |
4,448 | public function deleteBackup ( $ backupName ) { Service :: $ log -> msg ( 'Filesystem: deleting backup ' . $ backupName ) ; $ destinationFile = $ this -> storagePath . $ backupName ; if ( file_exists ( $ destinationFile ) ) { unlink ( $ destinationFile ) ; } Service :: $ log -> msg ( 'Filesystem: backup deleted ' . $ b... | Deletes a given backup from the filesystem . |
4,449 | public static function download ( $ url , $ output , $ verbose = false ) { $ curl = curl_init ( $ url ) ; $ folder = dirname ( $ output ) ; if ( ! is_dir ( $ folder ) ) { mkdir ( $ folder , 0755 , true ) ; } $ file = fopen ( $ output , "w" ) ; if ( $ verbose == true ) { curl_setopt ( $ curl , CURLOPT_VERBOSE , true ) ;... | Downloads file from internet . |
4,450 | protected function getContentAsArray ( Request $ request ) { $ content = json_decode ( $ request -> getContent ( ) , true ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new BadRequestException ( ) ; } if ( $ content === null ) { return [ ] ; } return $ content ; } | Get a JSON decoded array from the request content |
4,451 | public function actionAdditem ( ) { $ type = Yii :: $ app -> request -> post ( 'type' ) ; $ diyId = Yii :: $ app -> request -> post ( 'diyId' ) ; $ containerId = Yii :: $ app -> request -> post ( 'containerId' ) ; $ positionId = Yii :: $ app -> request -> post ( 'positionId' ) ; $ numberColumn = Yii :: $ app -> request... | Ham add 1 item vao trong layout |
4,452 | private function addContainer ( $ diyId , $ itemId ) { $ template = Diy :: generateTemplateContainer ( $ diyId , $ itemId ) ; $ model = Diy :: find ( ) -> where ( [ '_id' => $ diyId ] ) -> one ( ) ; if ( $ model ) { if ( empty ( $ model -> data ) ) { $ model -> data = [ $ itemId => [ ] ] ; } else { $ model -> data = Ar... | Ham generate template container va add container vao database |
4,453 | private function addPosition ( $ diyId , $ itemId , $ containerId , $ numberColumn ) { $ template = Diy :: generateTemplatePosition ( $ numberColumn , $ diyId , $ containerId , $ itemId ) ; $ model = Diy :: find ( ) -> where ( [ '_id' => $ diyId ] ) -> one ( ) ; if ( $ model ) { $ container = ArrayHelper :: getValue ( ... | Ham add mot position vao container |
4,454 | private function addWidget ( $ diyId , $ itemId , $ containerId , $ positionId , $ draggable_id ) { $ template = DiyWidget :: generateTemplateSetting ( $ containerId , $ positionId , $ itemId , $ draggable_id , [ ] ) ; $ model = Diy :: find ( ) -> where ( [ '_id' => $ diyId ] ) -> one ( ) ; if ( $ model ) { $ position ... | Ham them moi mot widget vao position |
4,455 | public function generate ( $ parameters = [ ] ) { $ content = $ this -> getContent ( ) ; if ( count ( $ parameters ) ) { foreach ( $ parameters as $ param => $ value ) { $ content = str_replace ( "{{ $param }}" , $ value , $ content ) ; } } return $ content ; } | create the new content |
4,456 | public function isRegistered ( $ identifier , $ type = "" ) { try { $ this -> getESAdaptor ( ) -> getDocument ( $ identifier , $ this -> section , $ type ) ; } catch ( NotFoundException $ e ) { return false ; } return true ; } | Verifies a document is in the elasticsearch index . |
4,457 | protected function getRegistryIndex ( $ section , array $ indexOptions = array ( ) , $ specials = null ) { if ( empty ( $ this -> registry [ $ section ] ) ) { $ this -> registry [ $ section ] = $ this -> getESAdaptor ( ) -> getIndex ( $ section , $ indexOptions , $ specials ) ; } return $ this -> registry [ $ section ]... | Provides an elastic search index . |
4,458 | public function checkByFilter ( Filter $ filter , Message $ message ) { return $ this -> check ( $ filter -> getCriteria ( ) , $ message ) ; } | Check if message satisfies the given filter . |
4,459 | public function hasKeysInDepth ( $ haystack , $ keys ) { $ this -> validateInput ( $ haystack , $ keys ) ; return $ this -> getNode ( $ haystack , $ keys , static :: USAGE_EXISTS ) ; } | Verify if a key exist in depth |
4,460 | public function getValueFromDepth ( $ haystack , $ keys ) { $ this -> validateInput ( $ haystack , $ keys ) ; return $ this -> getNode ( $ haystack , $ keys , static :: USAGE_EXTRACT ) ; } | Get a value in depth of an array |
4,461 | private function validateInput ( $ haystack , $ keys ) { if ( ! is_array ( $ haystack ) || empty ( $ haystack ) ) { throw new \ InvalidArgumentException ( "Provided input array is either empty or not an array." ) ; } if ( ! is_array ( $ keys ) || empty ( $ keys ) ) { throw new \ InvalidArgumentException ( "Provided inp... | Validate if the given input are valid array |
4,462 | public function init ( ) { $ this -> filter = isset ( $ _REQUEST [ 'filter' ] ) ? $ _REQUEST [ 'filter' ] : [ ] ; $ this -> sort = isset ( $ _REQUEST [ 'sort' ] ) ? $ _REQUEST [ 'sort' ] : [ ] ; } | Init an object |
4,463 | public function indexAction ( Request $ request , $ nodeId ) { $ node = $ this -> responseHelper -> getNodeOr404 ( $ nodeId ) ; $ textNode = $ this -> getTextNode ( $ node ) ; $ form = $ this -> formFactory -> create ( $ textNode ) ; $ messages = new Messages ( ) ; if ( $ this -> formHandler -> process ( $ request , $ ... | Silvestra text node index action . |
4,464 | private function getTextNode ( NodeInterface $ node ) { $ textNode = $ this -> textNodeManager -> findTextNodeByNode ( $ node ) ; if ( null === $ textNode ) { $ textNode = $ this -> textNodeManager -> create ( ) ; $ text = $ this -> textManager -> create ( ) ; $ textNode -> setText ( $ text ) ; $ textNode -> setNode ( ... | Get text node . |
4,465 | private function renderTextNode ( FormInterface $ form , Messages $ messages = null ) { return $ this -> responseHelper -> render ( 'SilvestraTextNodeBundle:TextNode:index.html.twig' , array ( 'form' => $ form -> createView ( ) , 'messages' => $ messages , ) ) ; } | Render text node template . |
4,466 | public static function _isset ( $ value , array $ params , Template $ template ) { if ( ! isset ( $ value ) ) { return '' ; } $ placeholders = array_merge ( ! empty ( $ params [ 'addPlaceholders' ] ) ? $ template -> findPlaceholders ( $ params [ 'addPlaceholders' ] ) : [ ] , [ 'output' => $ value ] ) ; return $ templat... | isset condition . |
4,467 | public static function notIsset ( $ value = null , array $ params , Template $ template ) { if ( isset ( $ value ) ) { return $ value ; } $ placeholders = array_merge ( ! empty ( $ params [ 'addPlaceholders' ] ) ? $ template -> findPlaceholders ( $ params [ 'addPlaceholders' ] ) : [ ] , [ 'output' => $ value ] ) ; retu... | !isset condition . |
4,468 | public static function notEmpty ( $ value , array $ params , Template $ template ) { if ( empty ( $ value ) ) { return '' ; } $ placeholders = array_merge ( ! empty ( $ params [ 'addPlaceholders' ] ) ? $ template -> findPlaceholders ( $ params [ 'addPlaceholders' ] ) : [ ] , [ 'output' => $ value ] ) ; return $ templat... | Condition is not empty . |
4,469 | public static function _empty ( $ value = null , array $ params , Template $ template ) { if ( ! empty ( $ value ) ) { return $ value ; } $ placeholders = array_merge ( ! empty ( $ params [ 'addPlaceholders' ] ) ? $ template -> findPlaceholders ( $ params [ 'addPlaceholders' ] ) : [ ] , [ 'output' => $ value ] ) ; retu... | Condition is empty . |
4,470 | public static function inotEmpty ( $ value , array $ params , Template $ template ) { if ( empty ( $ value ) ) { return '' ; } $ template = clone $ template ; $ placeholders = array_merge ( ! empty ( $ params [ 'addPlaceholders' ] ) ? $ template -> findPlaceholders ( $ params [ 'addPlaceholders' ] ) : [ ] , [ 'output' ... | Inline condition is not empty . |
4,471 | public static function iempty ( $ value = null , array $ params , Template $ template ) { if ( ! empty ( $ value ) ) { return $ value ; } $ template = clone $ template ; $ placeholders = array_merge ( ! empty ( $ params [ 'addPlaceholders' ] ) ? $ template -> findPlaceholders ( $ params [ 'addPlaceholders' ] ) : [ ] , ... | Inline condition is empty . |
4,472 | private static function _getCondition ( $ value , array $ conditions ) { if ( empty ( $ value ) || empty ( $ conditions ) ) { return false ; } return current ( array_intersect ( array_keys ( $ value ) , $ conditions ) ) ; } | Get name of condition . |
4,473 | public function addTranslation ( Translation $ translation ) { $ key = "{$translation->language()}::{$translation->domain()}" ; $ name = "{$translation->domain()}{$this->types[$translation->type()]}" ; $ this -> translationService ( ) -> addTranslationFilePattern ( $ translation -> type ( ) , $ translation -> path ( ) ... | Adds a translation to the translator |
4,474 | public static function _isSSL ( ) { if ( isset ( $ _SERVER ) && ( isset ( $ _SERVER [ 'HTTPS' ] ) && $ _SERVER [ "HTTPS" ] == "on" ) || ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] ) && $ _SERVER [ "HTTP_X_FORWARDED_PROTO" ] == "https" ) ) { return TRUE ; } return FALSE ; } | Determines whether the connection is over SSL HTTP_X_FORWARDED_PROTO |
4,475 | public function edit ( ) { if ( $ this -> request -> is ( 'post' ) && ! empty ( $ this -> request -> data ) ) { if ( isset ( $ this -> request -> data [ 'data' ] ) ) { foreach ( $ this -> request -> data [ 'data' ] ?? [ ] as $ attribute => $ value ) { $ this -> request -> data [ $ attribute ] = $ value ; unset ( $ this... | edit action POST |
4,476 | public static function newConnection ( $ param , $ user , $ pass ) : IConnect { return new MYSQL ( new ParamConnection ( $ param , $ user , $ pass ) ) ; } | Metodo de factoria que inicializa el objeto . |
4,477 | public function retrieve ( $ name , $ force = false ) { $ RagnarokParameters = new self ( $ this -> SecParameter ) ; if ( self :: check ( ) ) { $ RagnarokParameters = Session :: get ( $ this -> getName ( ) ) ; if ( property_exists ( $ RagnarokParameters , $ name ) ) { if ( $ force ) { $ value = $ this -> SecParameter -... | Get value of a RagnarokParameter attribute |
4,478 | public function createNew ( string $ name , bool $ pass , string $ confidenceLevel = '' ) : array { $ array = [ 'name' => $ name , 'pass' => $ pass ] ; if ( ! empty ( $ confidenceLevel ) ) { $ array [ 'confidence_level' ] = $ confidenceLevel ; } return $ this -> sendPost ( sprintf ( '/profiles/%s/gates' , $ this -> use... | Creates a new gate for the given user . |
4,479 | public function upsertOne ( string $ name , bool $ pass ) : array { $ array = [ 'name' => $ name , 'pass' => $ pass ] ; if ( ! empty ( $ confidenceLevel ) ) { $ array [ 'confidence_level' ] = $ confidenceLevel ; } return $ this -> sendPut ( sprintf ( '/profiles/%s/gates' , $ this -> userName ) , [ ] , $ array ) ; } | Tries to update a gate and if it doesnt exists creates a new gate . |
4,480 | public function updateOne ( string $ gateSlug , bool $ pass ) : array { return $ this -> sendPatch ( sprintf ( '/profiles/%s/gates/%s' , $ this -> userName , $ gateSlug ) , [ ] , [ 'pass' => $ pass ] ) ; } | Updates a gate given its slug . |
4,481 | protected function renderVersion ( ) { return Line :: begin ( 'Caviar' , Line :: MAGENTA ) -> text ( 'version' ) -> text ( $ this -> version , Line :: YELLOW ) -> nl ( 2 ) ; } | Renders the a text containing the current version of Caviar . |
4,482 | protected function removeDirectory ( $ path ) { if ( ! is_dir ( $ path ) ) { return ; } foreach ( scandir ( $ path ) as $ entry ) { if ( $ entry === '.' || $ entry === '..' ) { continue ; } $ entryPath = $ path . '/' . $ entry ; if ( is_dir ( $ entryPath ) ) { $ this -> removeDirectory ( $ entryPath ) ; } else { unlink... | Removes a specific directory . |
4,483 | protected function normalizePath ( $ filePath ) { if ( ( $ path = \ Yii :: getPathOfAlias ( $ filePath ) ) !== false ) { $ filePath = $ path ; } return $ filePath ; } | Normalizes the given file path by converting aliases to real paths . |
4,484 | public function config ( $ options ) { if ( is_array ( $ options ) ) { $ this -> EightdownConfig = array_merge ( $ this -> EightdownConfig , $ options ) ; $ this -> setBreaksEnabled ( ! ! $ this -> config ( 'general.keepLineBreaks' ) ) -> setMarkupEscaped ( ! $ this -> config ( 'general.parseHTML' ) ) -> setUrlsLinked ... | Configures the instance using an array . |
4,485 | protected function imageFlipVertical ( ) { $ x_i = imagesx ( $ this -> workingImage ) ; $ y_i = imagesy ( $ this -> workingImage ) ; for ( $ x = 0 ; $ x < $ x_i ; $ x ++ ) { for ( $ y = 0 ; $ y < $ y_i ; $ y ++ ) { imagecopy ( $ this -> workingImage , $ this -> workingImage , $ x , $ y_i - $ y - 1 , $ x , $ y , 1 , 1 )... | Flips the image vertically |
4,486 | protected function hex2rgb ( $ hex , $ asString = false ) { if ( 0 === strpos ( $ hex , '#' ) ) { $ hex = substr ( $ hex , 1 ) ; } elseif ( 0 === strpos ( $ hex , '&H' ) ) { $ hex = substr ( $ hex , 2 ) ; } $ cutpoint = ceil ( strlen ( $ hex ) / 2 ) - 1 ; $ rgb = explode ( ':' , wordwrap ( $ hex , $ cutpoint , ':' , $ ... | Converts a hex color to rgb tuples |
4,487 | public function numberOfPages ( ) { if ( $ this -> totalAmount == 0 ) { return 0 ; } $ cantidad = $ this -> totalAmount / $ this -> amountPerPage ; if ( is_int ( $ cantidad ) ) { return $ cantidad ; } else { $ cantidad_int = intval ( $ cantidad ) ; if ( $ cantidad_int > $ cantidad ) { return $ cantidad_int ; } else { r... | Retorna la cantidad de paginas |
4,488 | public function elementEndPosition ( ) { if ( $ this -> numberOfPages ( ) == $ this -> currentPage ) { return $ this -> totalAmount - ( 1 - $ this -> startPosition ) ; } else { return $ this -> elementStartPosition ( ) + $ this -> amountPerPage - 1 ; } } | Retorna la posicion del elemento de fin de la pagina actual . |
4,489 | public function jsonSerialize ( ) { return array ( 'count' => $ this -> totalAmount , 'countOfPages' => $ this -> numberOfPages ( ) , 'limit' => $ this -> amountPerPage , 'page' => $ this -> currentPage , 'previousPage' => $ this -> previousPage ( ) , 'nextPage' => $ this -> nextPage ( ) ) ; } | Retorna un arreglo con los valores de informacion del paginador |
4,490 | public function getImage ( $ path ) { $ lang = Yii :: $ app -> language ; $ test = '/' . $ lang . $ path ; if ( self :: fileExists ( $ test ) ) { return $ this -> hostUrl . "/" . $ this -> siteFolder . $ test ; } else { return $ this -> hostUrl . "/" . $ this -> siteFolder . "/" . $ this -> defaultLang . $ path ; } } | Calls fileExists and returns an image path if true . |
4,491 | public function fileExists ( $ path ) { $ ch = curl_init ( $ this -> hostUrl . "/" . $ this -> siteFolder . $ path ) ; curl_setopt ( $ ch , CURLOPT_NOBODY , true ) ; $ result = curl_exec ( $ ch ) ; $ ret = false ; if ( $ result !== false ) { $ status = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; if ( $ status == 200 )... | Checks if the requested image exists and returns true or false . |
4,492 | static public function validate ( $ datetime ) { $ parts = preg_split ( '/[T ]/' , $ datetime ) ; return Date :: validate ( $ parts [ 0 ] ) && Time :: validate ( $ parts [ 1 ] ) ; } | Validate if a string is a datetime |
4,493 | public function validateId ( $ id ) { if ( null === $ id ) { throw new \ InvalidArgumentException ( 'Category id missing' ) ; } elseif ( ! is_numeric ( $ id ) || ( int ) $ id != $ id ) { throw new \ InvalidArgumentException ( 'Invalid data type for category id' ) ; } } | Validates the ID of an entity |
4,494 | public function getTableName ( ) { if ( null == $ this -> tableName ) { $ this -> tableName = $ this -> determineTableName ( ) ; } return $ this -> tableName ; } | Gets entity table name |
4,495 | public function getFields ( ) { if ( null == $ this -> fields ) { $ properties = $ this -> inspector -> getClassProperties ( ) ; $ this -> fields = new FieldsCollection ( ) ; foreach ( $ properties as $ property ) { $ this -> addDescriptor ( $ property ) ; } } return $ this -> fields ; } | Returns entity fields |
4,496 | public function getPrimaryKey ( ) { if ( null == $ this -> primaryKey ) { foreach ( $ this -> getFields ( ) as $ field ) { if ( $ field -> isPrimaryKey ( ) ) { $ this -> primaryKey = $ field ; break ; } } } return $ this -> primaryKey ; } | Returns the primary key field |
4,497 | public static function addRelation ( $ annotationName , $ relationClass ) { if ( ! is_subclass_of ( $ relationClass , RelationInterface :: class ) ) { throw new InvalidArgumentException ( "'{$relationClass}' is not a RelationInterface class." ) ; } static :: $ knownRelations [ $ annotationName ] = $ relationClass ; } | Adds a relation class to the list of known relation classes |
4,498 | private function determineTableName ( ) { $ annotations = $ this -> inspector -> getClassAnnotations ( ) ; $ name = self :: parseTableName ( $ this -> entity ) ; if ( $ annotations -> hasAnnotation ( '@table' ) ) { $ name = $ annotations -> getAnnotation ( '@table' ) -> getValue ( ) ; } return $ name ; } | Determines the table name for current entity |
4,499 | public static function parseTableName ( $ className ) { $ parts = explode ( '\\' , $ className ) ; $ name = end ( $ parts ) ; $ tableName = null ; $ words = explode ( '#' , Text :: camelCaseToSeparator ( $ name , "#" ) ) ; $ last = array_pop ( $ words ) ; $ last = Text :: plural ( strtolower ( $ last ) ) ; array_push (... | Parses the table name from the class name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.