idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
8,900 | private function setExpiration ( $ expires_in ) { $ this -> expiresAtTimestamp = time ( ) + $ expires_in ; $ this -> expiresAt = date ( 'Y-m-d H:i:s' , time ( ) + $ expires_in ) ; } | Set the expiration time for the token |
8,901 | private function setAcquisitionTime ( ) { if ( is_null ( $ this -> acquisitionTime ) ) { $ this -> acquisitionTime = date ( 'Y-m-d H:i:s' ) ; $ this -> acquisitionTimestamp = time ( ) ; } ; } | Set the acquisition time of the token |
8,902 | public function findOneById ( $ seoId ) { $ qb = $ this -> createQueryBuilder ( 's' ) ; $ query = $ qb -> andWhere ( $ qb -> expr ( ) -> eq ( 's.id' , $ seoId ) ) -> setMaxResults ( 1 ) -> getQuery ( ) ; return $ query -> getOneOrNullResult ( ) ; } | Finds the seo by his id . |
8,903 | private function mount ( array & $ array , string $ path , $ message ) { if ( $ path == '.' ) { throw new MapperException ( "Unable to mount error `{$message}` to `{$path}` (root path is forbidden)" ) ; } $ step = explode ( '.' , $ path ) ; while ( $ name = array_shift ( $ step ) ) { $ array = & $ array [ $ name ] ; } ... | Set element using dot notation . |
8,904 | private function iterate ( InputInterface $ input , array $ map ) : \ Generator { $ values = $ input -> getValue ( $ map [ self :: ITERATE_SOURCE ] , $ map [ self :: ITERATE_ORIGIN ] ) ; if ( empty ( $ values ) || ! is_array ( $ values ) ) { return [ ] ; } foreach ( array_keys ( $ values ) as $ key ) { yield $ key => $... | Create set of origins and prefixed for a nested array of models . |
8,905 | public function setPathData ( Path $ path = null , $ active = true , $ limited = false , $ inSitemap = true ) { $ this -> getPathEntity ( ) -> setPath ( $ path ) ; $ this -> getPathEntity ( ) -> setActive ( $ active ) ; $ this -> getPathEntity ( ) -> setVisibleInSitemap ( $ inSitemap ) ; } | Set page path Should be called from the PagePathGenerator only! |
8,906 | public function getFullPath ( $ format = Path :: FORMAT_NO_DELIMITERS ) { $ pathString = $ this -> getPath ( ) -> getFullPath ( $ format ) ; return $ pathString ; } | Shortcut for accessing the full page path |
8,907 | private function getRealPath ( $ activeOnly ) { $ path = $ this -> getPathEntity ( ) -> getPath ( ) ; $ active = $ this -> getPathEntity ( ) -> isActive ( ) ; if ( is_null ( $ path ) ) { $ path = NullPath :: getInstance ( ) ; $ this -> getPathEntity ( ) -> setPath ( $ path ) ; } elseif ( $ activeOnly && ! $ active ) { ... | Will return real path or null path record if page not active and only active path is requested . |
8,908 | public function setPathPart ( $ pathPart ) { $ pathPart = strtr ( $ pathPart , array ( '/' => '' , '\\' => '' , '#' => '' , '?' => '' , ' ' => '' , '%' => '' ) ) ; $ pathPart = trim ( $ pathPart ) ; $ this -> pathPart = $ pathPart ; } | Sets path part of the page |
8,909 | public function isPublic ( ) { if ( ! $ this -> active ) { return false ; } $ pathEntity = $ this -> getPathEntity ( ) ; return $ pathEntity -> isActive ( ) && $ pathEntity -> getPath ( ) !== null ; } | Whether the page is available |
8,910 | public function voArray ( VOArray $ arrayValueObject ) { if ( $ key = VOArray :: fromArray ( $ this -> getValue ( ) ) -> getKey ( $ arrayValueObject -> current ( ) ) ) { return $ arrayValueObject -> isLast ( ) ? $ key : static :: fromArray ( $ key ) -> voArray ( $ arrayValueObject -> dropFirst ( ) ) ; } return false ; ... | Iterates through an array of values and finds a key . If it makes it to the final value it returns what ever value matches that key . |
8,911 | protected function findLocalizedAsset ( $ locale , $ asset ) { $ localized = $ this -> doFindLocalizedAsset ( $ locale , $ asset ) ; if ( 0 === \ count ( $ localized ) ) { $ localized = $ this -> doFindLocalizedAsset ( $ this -> getFallbackLocale ( ) , $ asset ) ; } return $ localized ; } | Find the localized asset . |
8,912 | protected function doFindLocalizedAsset ( $ locale , $ asset ) { if ( isset ( $ this -> assets [ $ locale ] [ $ asset ] ) ) { return $ this -> assets [ $ locale ] [ $ asset ] ; } if ( 0 < $ pos = strpos ( $ locale , '_' ) ) { return $ this -> doFindLocalizedAsset ( substr ( $ locale , 0 , $ pos ) , $ asset ) ; } return... | Do find the localized asset . |
8,913 | protected function getCurrentLocale ( $ locale = null ) { return null !== $ locale ? LocaleUtils :: formatLocale ( $ locale ) : $ this -> getLocale ( ) ; } | Get the current locale . |
8,914 | protected function cleanArray ( $ property , $ key , $ subKey ) : void { $ val = & $ this -> { $ property } ; unset ( $ val [ $ key ] [ $ subKey ] ) ; if ( \ array_key_exists ( $ key , $ val ) && 0 === \ count ( $ val [ $ key ] ) ) { unset ( $ val [ $ key ] ) ; } } | Clean the array . |
8,915 | public function setRequiredFields ( $ fields ) { $ this -> requiredFields = $ fields ; $ this -> setValidator ( $ this -> getValidator ( ) ) ; return $ this ; } | setRequiredFields Resets everything if the fields change |
8,916 | public function getFieldSource ( ) { if ( is_callable ( self :: $ field_source ) ) { $ fields = call_user_func ( self :: $ field_source , $ this ) ; if ( ! $ fields instanceof FieldList ) { throw new InvalidArgumentException ( 'Field source must be callable and return a FieldList' ) ; } return $ fields ; } return new F... | Uses the field_source defined or falls back to the Member s getCMSFields |
8,917 | public function populateFromSources ( SS_HTTPRequest $ request = null , Member $ member = null , array $ required = null ) { $ dataPath = "FormInfo.{$this->FormName()}.data" ; if ( isset ( $ member ) ) { $ this -> loadDataFrom ( $ member ) ; } else if ( isset ( $ request ) ) { $ this -> loadDataFrom ( $ request -> post... | Populates the form somewhat intelligently |
8,918 | public function paginate ( $ perPage = 15 , $ page = null , $ options = [ ] , $ setPath = null ) { $ page = $ page ? : ( Paginator :: resolveCurrentPage ( ) ? : 1 ) ; $ items = ( $ this instanceof Collection || $ this instanceof PostCollection ) ? $ this : Collection :: make ( $ this ) ; $ paginator = new LengthAwarePa... | Create a pagination of items from array or collection . |
8,919 | public function orderBy ( $ key , $ mode = 'ASC' , $ options = SORT_REGULAR ) { return $ this -> sortBy ( $ key , $ options , ( $ mode === 'DESC' ? true : false ) ) ; } | Perform order by . It performs similar to sortBy method of collection but simplifies parameter order . |
8,920 | public function whereJson ( $ key , $ operator , $ value = null ) { return $ this -> filter ( $ this -> jsonOperator ( ... func_get_args ( ) ) ) ; } | Where json operator . |
8,921 | public function jsonOperator ( $ key , $ operator , $ value = null ) { if ( func_num_args ( ) === 2 ) { $ value = $ operator ; $ operator = '=' ; } return function ( $ item ) use ( $ key , $ operator , $ value ) { $ column = $ key ; if ( Str :: contains ( $ key , '->' ) ) { $ explodeKey = explode ( '->' , $ key ) ; $ c... | Where json operator . It currently supports only level of json depth . |
8,922 | public function setModel ( $ eloquent , $ table ) { self :: $ _pathToClass = $ eloquent ; self :: $ _modelTable = $ table ; return $ this ; } | Set model path and table to be appended later on cache items . |
8,923 | public function getItems ( $ pathToClass = null , $ table = null ) { if ( ! $ pathToClass ) { $ pathToClass = self :: $ _pathToClass ; } if ( ! $ table ) { $ table = self :: $ _modelTable ; } $ backtrace = debug_backtrace ( ) ; return $ this -> map ( function ( $ item ) use ( $ pathToClass , $ table ) { $ modelInstance... | Appends a model to each of cache items . |
8,924 | public function refreshState ( $ cacheName , $ item , $ mode , $ limitCache ) { $ cachedItems = $ this -> all ( ) ; $ currentItemKey = null ; if ( $ cachedItems ) { $ keyName = $ item -> getKeyName ( ) ; $ keyValue = $ item -> getKey ( ) ; foreach ( $ cachedItems as $ index => $ row ) { if ( $ row [ $ keyName ] == $ ke... | Add update or remove an item from cache . |
8,925 | public function renderView ( $ template , $ data = [ ] ) { $ template = $ this -> di -> get ( "views" ) -> getTemplateFile ( $ template ) ; $ view = $ this -> di -> get ( "view" ) ; $ view -> setDI ( $ this -> di ) ; $ view -> set ( $ template , $ data ) ; $ view -> render ( ) ; } | Render a view with an optional data set of variables . |
8,926 | public function classList ( ... $ args ) { $ classes = [ ] ; foreach ( $ args as $ arg ) { if ( empty ( $ arg ) ) { continue ; } elseif ( is_string ( $ arg ) ) { $ arg = explode ( " " , $ arg ) ; } $ classes = array_merge ( $ classes , $ arg ) ; } return "class=\"" . implode ( " " , $ classes ) . "\"" ; } | Create a class attribute from a string or array . |
8,927 | public function getContentForRoute ( $ route ) { $ content = $ this -> di -> get ( "content" ) -> contentForInternalRoute ( $ route ) ; return $ content -> views [ "main" ] [ "data" ] ; } | Load content from a route and return details to view . |
8,928 | public function wrapElementWithStartEnd ( $ text , $ tag , $ start , $ end , $ count ) { return $ this -> di -> get ( "textFilter" ) -> wrapElementWithStartEnd ( $ text , $ tag , $ start , $ end , $ count ) ; } | Wrap a HTML element with start and end . |
8,929 | public function getPublishedDate ( $ dates ) { $ defaults = [ "revision" => [ ] , "published" => null , "updated" => null , "created" => null , ] ; $ dates = array_merge ( $ defaults , $ dates ) ; if ( $ dates [ "revision" ] ) { return [ t ( "Latest revision" ) , key ( $ dates [ "revision" ] ) ] ; } elseif ( $ dates [ ... | Extrat the publish or update date for the article . |
8,930 | private function getAddCartForm ( Request $ request ) { if ( $ request -> isMethod ( "post" ) ) { $ cartAdd = $ this -> createForm ( FrontForm :: CART_ADD ) ; } else { $ cartAdd = $ this -> createForm ( FrontForm :: CART_ADD , "form" , array ( ) , array ( 'csrf_protection' => false , ) ) ; } return $ cartAdd ; } | Find the good way to construct the cart form |
8,931 | public function editAction ( $ externalNetworkId , $ dom_id , $ timetableId , $ block_type = 'text' , $ stop_point = null ) { $ blockTypeFactory = $ this -> get ( 'canal_tp_mtt.form.factory.block' ) ; $ blockManager = $ this -> get ( 'canal_tp_mtt.block_manager' ) ; $ timetableManager = $ this -> get ( 'canal_tp_mtt.ti... | returns form for a given block type or save content of the block using Form factory |
8,932 | protected function sendExceptionToSentry ( $ exception ) { if ( ! Bootstrap :: $ staticObjectManager instanceof ObjectManagerInterface ) { return ; } $ options = $ this -> resolveCustomRenderingOptions ( $ exception ) ; if ( isset ( $ options [ 'logException' ] ) && $ options [ 'logException' ] ) { try { $ errorHandler... | Send an exception to Sentry but only if the logException rendering option is TRUE |
8,933 | public static function fromString ( $ string ) { return ctype_digit ( $ string ) ? new static ( ( int ) $ string ) : self :: fromNative ( new \ DateTime ( $ string ) ) ; } | From String . |
8,934 | public static function createFromGlobals ( ) { $ request = new static ; $ request -> get -> setAll ( $ _GET ) ; $ request -> post -> setAll ( $ _POST ) ; $ request -> setFiles ( $ _FILES ) ; $ request -> header -> setAll ( static :: getAllHeaders ( ) ) ; $ request -> server -> setAll ( $ _SERVER ) ; $ request -> cookie... | Create a Request from the global inputs . |
8,935 | public function setFiles ( $ files ) { $ files = $ this -> parseFiles ( $ files ) ; $ this -> file -> setAll ( $ files ) ; } | Set the files . |
8,936 | protected function parseFiles ( array $ raw ) { if ( isset ( $ raw [ 'name' ] ) && isset ( $ raw [ 'type' ] ) && isset ( $ raw [ 'tmp_name' ] ) && isset ( $ raw [ 'error' ] ) && isset ( $ raw [ 'size' ] ) ) { if ( is_array ( $ raw [ 'name' ] ) ) { $ name = $ this -> convertTo ( 'name' , $ raw [ 'name' ] ) ; $ type = $ ... | Parse FILE input and return HttpFile objects . |
8,937 | public function add ( Node \ NodeInterface $ node ) { $ node -> setRepository ( $ this ) ; parent :: add ( $ node ) ; $ this -> array [ ] = $ node ; } | Add the node to the repository |
8,938 | public function createNode ( $ title = null ) { $ node = new Node \ ArrayNode ( ) ; $ node -> setNodeTitle ( $ title ) ; $ this -> add ( $ node ) ; return $ node ; } | New node factory |
8,939 | public function delete ( Node \ NodeInterface $ node ) { $ left = $ node -> getLeftValue ( ) ; $ right = $ node -> getRightValue ( ) ; foreach ( $ this -> array as $ key => $ item ) { if ( $ item -> getLeftValue ( ) >= $ left && $ item -> getRightValue ( ) <= $ right ) { unset ( $ this -> array [ $ key ] ) ; } } } | Delete the node |
8,940 | public function search ( SearchCondition \ SearchConditionInterface $ filter , SelectOrder \ SelectOrderInterface $ order = null ) { if ( ! ( $ filter instanceof SearchCondition \ ArraySearchCondition ) ) { throw new Exception \ WrongInstance ( $ filter , 'SearchCondition\ArraySearchCondition' ) ; } $ filterClosure = $... | Perform the search in the array |
8,941 | public function searchByClosure ( \ Closure $ filterClosure , \ Closure $ orderClosure = null ) { $ result = array ( ) ; foreach ( $ this -> array as $ item ) { if ( $ filterClosure ( $ item ) ) { $ result [ ] = $ item ; } } if ( ! \ is_null ( $ orderClosure ) ) { usort ( $ result , $ orderClosure ) ; } return $ result... | Perform data select by search and order closures |
8,942 | public function check ( $ value , $ rules , $ throws = false ) { $ tests = [ 'fail' => [ 'message' => 'Will always fail.' , 'test' => function ( ) { return false ; } , ] , 'pass' => [ 'message' => 'Will always pass.' , 'test' => function ( ) { return true ; } , ] , 'not_empty' => [ 'message' => 'Can not be empty.' , 't... | Check if a value matches rules or throw exception . |
8,943 | public function find ( $ fileId , $ type = null ) { if ( ! is_string ( $ fileId ) ) { return null ; } if ( empty ( $ type ) ) { $ type = FileAbstraction :: CN ( ) ; } return $ this -> getDoctrineEntityManager ( ) -> find ( $ type , $ fileId ) ; } | Searches for any File Storage entity by entity ID . Result can be File Image or Folder . |
8,944 | public function validateFileUpload ( File $ file , $ sourceFilePath = null ) { foreach ( $ this -> fileUploadFilters as $ filter ) { $ filter -> validateFile ( $ file , $ sourceFilePath ) ; } } | Validates against filters |
8,945 | public function storeFileData ( File $ file , $ sourceFilePath ) { $ this -> validateFileUpload ( $ file , $ sourceFilePath ) ; $ this -> createBothFoldersInFileSystem ( $ file ) ; $ filePath = $ this -> getFilesystemPath ( $ file ) ; if ( ! copy ( $ sourceFilePath , $ filePath ) ) { throw new Exception \ RuntimeExcept... | Store file data |
8,946 | public function renameFile ( File $ file , $ fileName ) { $ entityManager = $ this -> getDoctrineEntityManager ( ) ; $ originFile = clone ( $ file ) ; $ entityManager -> detach ( $ originFile ) ; try { $ file -> setFileName ( $ fileName ) ; } catch ( \ Exception $ e ) { throw new Exception \ UploadFilterException ( sel... | Rename file in all file storages |
8,947 | public function renameFolder ( Folder $ folder , $ newTitle ) { $ entityManager = $ this -> getDoctrineEntityManager ( ) ; $ entityManager -> beginTransaction ( ) ; $ oldFolder = clone ( $ folder ) ; $ entityManager -> detach ( $ oldFolder ) ; try { $ folder -> setFileName ( $ newTitle ) ; foreach ( $ this -> folderUpl... | Rename folder in all file storages . Doesn t involve moving the folder in another folder . |
8,948 | public function createFolder ( Folder $ folder ) { foreach ( $ this -> folderUploadFilters as $ filter ) { $ filter -> validateFolder ( $ folder ) ; } $ this -> createBothFoldersInFileSystem ( $ folder ) ; } | Creates new folder in all file storages |
8,949 | public function setPublic ( FileAbstraction $ file , $ public = true ) { if ( $ file instanceof File ) { $ this -> setPublicForFile ( $ file , $ public ) ; } else if ( $ file instanceof Folder ) { $ this -> setPublicForFolder ( $ file , $ public ) ; } else { throw new Exception \ RuntimeException ( 'Wrong entity passed... | Moves file or folder to public storage |
8,950 | private function moveFileToExternalStorage ( $ filePath , Folder $ folder = null ) { $ oldPath = $ this -> getInternalPath ( ) . $ filePath ; $ newPath = $ this -> getExternalPath ( ) . $ filePath ; $ this -> createBothFoldersInFileSystem ( $ folder ) ; if ( ! rename ( $ oldPath , $ newPath ) ) { $ filename = basename ... | Actual file move to external storage |
8,951 | public function getImageSizeName ( $ targetWidth , $ targetHeight , $ cropped = false ) { $ sizeName = $ targetWidth . 'x' . $ targetHeight ; if ( $ cropped ) { $ sizeName .= 'cropped' ; } return $ sizeName ; } | Returns image size name based on image height weight and cropped flag |
8,952 | protected function recreateImageSizes ( Image $ file ) { if ( ! $ file instanceof Image ) { throw new Exception \ RuntimeException ( 'Image entity expected' ) ; } $ sizes = $ file -> getImageSizeCollection ( ) ; if ( ! $ sizes -> isEmpty ( ) ) { foreach ( $ sizes as $ size ) { $ sizeName = $ size -> getName ( ) ; $ fil... | Recreate all existing resized versions of the image |
8,953 | public function rotateImageLeft ( Image $ file , $ quality = 95 ) { $ this -> rotateImage ( $ file , ImageProcessor \ ImageRotator :: ROTATE_LEFT , $ quality ) ; } | Rotate image by 90 degrees CCW |
8,954 | public function rotateImageRight ( Image $ file , $ quality = 95 ) { $ this -> rotateImage ( $ file , ImageProcessor \ ImageRotator :: ROTATE_RIGHT , $ quality ) ; } | Rotate image by 90 degrees CW |
8,955 | public function rotateImage180 ( Image $ file , $ quality = 95 ) { $ this -> rotateImage ( $ file , ImageProcessor \ ImageRotator :: ROTATE_180 , $ quality ) ; } | Rotate image by 180 |
8,956 | public function getMimeType ( $ filename ) { if ( ! file_exists ( $ filename ) ) { throw new Exception \ RuntimeException ( 'File does not exist' ) ; } $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mimeType = finfo_file ( $ finfo , $ filename ) ; finfo_close ( $ finfo ) ; return $ mimeType ; } | Get mime type of file |
8,957 | public function isSupportedImageFormat ( $ filename ) { $ info = new ImageInfo ( $ filename ) ; if ( $ info -> hasError ( ) ) { $ this -> container -> getLogger ( ) -> error ( $ info -> getError ( ) ) ; return false ; } if ( ! $ this -> isMimeTypeImage ( $ info -> getMime ( ) ) ) { return false ; } return ImageProcesso... | Is current image format supported by image processor |
8,958 | public function getImagePath ( Image $ file , $ sizeName = null ) { if ( ! $ file instanceof Image ) { throw new Exception \ RuntimeException ( 'Image entity expected' ) ; } $ path = $ this -> getFilesystemDir ( $ file ) ; $ size = $ file -> findImageSize ( $ sizeName ) ; if ( $ size instanceof ImageSize ) { $ path .= ... | Get full file path for image size |
8,959 | private function removeFileInFileSystem ( File $ file ) { $ filePath = $ this -> getFilesystemPath ( $ file ) ; if ( file_exists ( $ filePath ) ) { $ result = unlink ( $ filePath ) ; if ( ! $ result ) { throw new Exception \ RuntimeException ( "Could not delete '$filePath' from file storage" ) ; } } if ( $ file instanc... | Remove file in file system |
8,960 | public function remove ( FileAbstraction $ entity ) { $ eventArgs = new FileEvent ( ) ; $ eventArgs -> setFile ( $ entity ) ; $ this -> fireFileEvent ( FileEvent :: FILE_EVENT_PRE_DELETE , $ eventArgs ) ; if ( $ entity instanceof Folder ) { $ hasChildren = $ entity -> hasChildren ( ) ; if ( $ hasChildren ) { throw new ... | Remove file or folder from database and system |
8,961 | private function removeFolder ( Folder $ folder ) { $ this -> removeFolderInFileSystem ( $ folder ) ; $ entityManager = $ this -> getDoctrineEntityManager ( ) ; $ entityManager -> remove ( $ folder ) ; $ entityManager -> flush ( ) ; } | Remove folder from database and file system |
8,962 | private function removeFolderInFileSystem ( Folder $ folder ) { $ folderPath = $ folder -> getPath ( DIRECTORY_SEPARATOR , true ) ; $ folderExternalPath = $ this -> getExternalPath ( ) . $ folderPath ; $ folderInternalPath = $ this -> getInternalPath ( ) . $ folderPath ; foreach ( array ( $ folderExternalPath , $ folde... | Remove folder in file system |
8,963 | private function removeFile ( File $ file ) { $ this -> removeFileInFileSystem ( $ file ) ; if ( $ file instanceof Image ) { $ em = $ this -> getDoctrineEntityManager ( ) ; $ imageSizeCn = ImageSize :: CN ( ) ; $ em -> createQuery ( "DELETE FROM $imageSizeCn s WHERE s.master = :master" ) -> setParameter ( 'master' , $ ... | Remove file from database and file system |
8,964 | public function fileExists ( FileAbstraction $ file ) { $ path = $ this -> getFilesystemPath ( $ file ) ; $ fileExists = file_exists ( $ path ) ; return $ fileExists ; } | Checks if the file exists |
8,965 | public function findOneByName ( $ name ) { $ qb = $ this -> getQueryBuilder ( ) ; return $ qb -> leftJoin ( 'c.containers' , 'container' ) -> leftJoin ( 'container.rows' , 'row' ) -> leftJoin ( 'row.blocks' , 'block' ) -> leftJoin ( 'block.translations' , 'block_t' ) -> addSelect ( 'container' , 'row' , 'block' , 'bloc... | Finds the content by id . |
8,966 | public function findBySubject ( ContentSubjectInterface $ subject ) { $ content = $ subject -> getContent ( ) ; if ( null !== $ content && property_exists ( $ content , '__isInitialized__' ) && ! $ content -> { '__isInitialized__' } ) { $ qb = $ this -> getQueryBuilder ( ) ; $ qb -> leftJoin ( 'c.containers' , 'contain... | Finds the content by subject . |
8,967 | public function GenerateQrCode ( int $ acls = GnMashupLoginAcl :: None ) { $ qrCode = parent :: GenerateQrCodeInternal ( GnSettings :: GPSNOSE_COMMUNITY , TRUE , TRUE , $ acls ) ; return $ qrCode ; } | Generate the login QR - code for the admin - user . |
8,968 | public function getArray ( array $ options = array ( ) ) : array { $ content = $ this -> getContent ( ) ; if ( is_null ( $ content ) ) { return ( array ) $ content ; } return json_decode ( $ this -> content , true ) ; } | Get result data as array |
8,969 | public function getObject ( array $ options = array ( ) ) { $ content = $ this -> getContent ( ) ; if ( is_null ( $ content ) ) { return ( object ) $ content ; } return json_decode ( $ this -> content , false ) ; } | Get result data as object |
8,970 | public function moveToDir ( $ dir , $ mode = null ) { if ( $ this -> isIn ( $ dir ) ) return ; return $ this -> rename ( $ dir . '/' . $ this -> getName ( ) , $ mode ) ; } | Move the file to a directory . |
8,971 | public function isIn ( $ dir ) { if ( ! $ this -> formatPath ( $ dir ) ) return false ; return strpos ( $ this -> formatPath ( $ this -> src ( ) ) , $ this -> formatPath ( $ dir ) ) === 0 ; } | Check if the file is in a given directory . |
8,972 | public function delete ( ) { if ( $ r = \ Asgard \ File \ FileSystem :: delete ( $ this -> src ) ) { $ this -> src = null ; $ this -> name = null ; } return $ r ; } | Delete the file . |
8,973 | protected function checkIsNull ( $ input ) { $ isNull = $ this -> isNull ; if ( $ isNull ) return $ isNull ( $ input ) ; else return $ input === null || $ input === '' ; } | Check if the input is null . |
8,974 | protected function mergeErrors ( array $ errors1 , array $ errors2 ) { foreach ( $ errors2 [ 'rules' ] as $ name => $ rule ) { if ( isset ( $ errors1 [ 'rules' ] [ $ name ] ) ) { $ i = 1 ; while ( isset ( $ errors1 [ 'rules' ] [ $ name . '-' . $ i ] ) ) { $ i += 1 ; } $ name = $ name . '-' . $ i ; } $ errors1 [ 'rules'... | Merge two array of errors . |
8,975 | protected function getMessage ( ) { if ( $ message = $ this -> defaultMessage ) { } else $ message = ':attribute is not valid.' ; $ params = [ 'attribute' => $ this -> getName ( ) , ] ; return $ this -> format ( $ message , $ params ) ; } | Get the default error message . |
8,976 | protected function buildRuleMessage ( $ ruleName , $ rule = null , $ default = null , $ input = null ) { if ( $ message = $ this -> getRuleMessage ( $ ruleName ) ) { } elseif ( $ message = $ this -> getRegistry ( ) -> getMessage ( $ ruleName ) ) { } elseif ( $ rule !== null && $ message = $ rule -> getMessage ( ) ) { }... | Build the error message of a rule . |
8,977 | protected function format ( $ message , array $ params ) { if ( $ fm = $ this -> formatParameters ) $ fm ( $ params ) ; foreach ( $ params as $ k => $ v ) { if ( is_string ( $ v ) || is_numeric ( $ v ) ) $ message = str_replace ( ':' . $ k , $ v , $ message ) ; } return ucfirst ( $ message ) ; } | Format an error message . |
8,978 | protected function delete ( string $ key ) : void { $ this -> resolver ( ) -> where ( 'id' , '=' , $ this -> getKeyId ( $ key ) ) -> delete ( ) ; } | Remove data from database . |
8,979 | public function start ( ) { if ( $ this -> watcher !== null ) { return ; } $ this -> watcher = Loop :: repeat ( $ this -> checkInterval , function ( ) { Loop :: unreference ( Loop :: defer ( $ this -> check ) ) ; } ) ; Loop :: unreference ( $ this -> watcher ) ; } | Start the detector . |
8,980 | public function stop ( ) { if ( $ this -> watcher === null ) { return ; } Loop :: cancel ( $ this -> watcher ) ; $ this -> watcher = null ; } | Stop the detector . |
8,981 | public function deliverView ( ) { $ this -> checkAuth ( ) ; $ this -> checkCartNotEmpty ( ) ; $ cart = $ this -> getSession ( ) -> getSessionCart ( $ this -> getDispatcher ( ) ) ; $ deliveryAddress = $ this -> getCustomerAddress ( ) ; if ( $ cart -> isVirtual ( ) ) { if ( null !== $ deliveryAddress ) { $ deliveryModule... | Check if the cart contains only virtual products . |
8,982 | public function invoice ( ) { $ this -> checkAuth ( ) ; $ this -> checkCartNotEmpty ( ) ; $ this -> checkValidDelivery ( ) ; $ message = false ; $ orderPayment = $ this -> createForm ( FrontForm :: ORDER_PAYMENT ) ; try { $ form = $ this -> validateForm ( $ orderPayment , "post" ) ; $ invoiceAddressId = $ form -> get (... | set invoice address set payment module |
8,983 | private function checkStockNotEmpty ( ) { $ cart = $ this -> getSession ( ) -> getSessionCart ( $ this -> getDispatcher ( ) ) ; $ cartItems = $ cart -> getCartItems ( ) ; foreach ( $ cartItems as $ cartItem ) { $ pse = $ cartItem -> getProductSaleElements ( ) ; $ product = $ cartItem -> getProduct ( ) ; if ( $ pse -> g... | Redirect to cart view if at least one non product is out of stock |
8,984 | protected function getCustomerAddress ( ) { $ deliveryAddress = null ; $ addressId = $ this -> getSession ( ) -> getOrder ( ) -> getChoosenDeliveryAddress ( ) ; if ( null === $ addressId ) { $ customer = $ this -> getSecurityContext ( ) -> getCustomerUser ( ) ; $ deliveryAddress = AddressQuery :: create ( ) -> filterBy... | Retrieve the chosen delivery address for a cart or the default customer address if not exists |
8,985 | protected function touchProperty ( $ propertyName ) { if ( in_array ( '$' . $ propertyName , $ this -> touchedProperties ) ) { return false ; } $ this -> touchedProperties [ ] = '$' . $ propertyName ; return true ; } | Add a property to the list of touched properties unless it is already present . |
8,986 | public function writePhpDoc ( ) { $ fileContents = file_get_contents ( $ this -> getFileName ( ) ) ; $ existingDoc = $ this -> getDocComment ( ) ; $ serializer = new DocBlock \ Serializer ( ) ; $ newDoc = $ serializer -> getDocComment ( $ this -> classDocBlock ) ; $ newDoc = str_replace ( '@SuppressWarnings (' , '@Supp... | Writes the updated DocBlock to the model s file |
8,987 | public function name ( $ aName = null ) { $ name = isset ( $ aName ) ? $ aName : ( isset ( $ this -> config [ 'name' ] ) ? $ this -> config [ 'name' ] : "anax" ) ; session_name ( $ name ) ; } | Set a session name or use one from config . |
8,988 | public function get ( $ key , $ default = null ) { return isset ( $ _SESSION ) && isset ( $ _SESSION [ $ key ] ) ? $ _SESSION [ $ key ] : $ default ; } | Get values from session . |
8,989 | public function readOnce ( $ key ) { $ read = $ this -> get ( $ key ) ; $ this -> delete ( $ key ) ; return $ read ; } | Read a value from the session and unset it a form of read once flash memory using the session . |
8,990 | public function isPasswordValid ( $ encoded , $ raw , $ salt ) { $ expectedHash = crypt ( ( string ) $ raw , $ encoded ) ; $ valid = ( $ expectedHash === $ encoded ) ; return $ valid ; } | Checks a raw password against an encoded password . |
8,991 | protected function installRuleset ( ) { if ( ! file_exists ( $ this -> pathRulesetLocal ) || $ this -> confirm ( 'Overwrite local configuration with our copy? (y/n) [y]' ) ) { $ copy = copy ( $ this -> pathRulesetStock , $ this -> pathRulesetLocal ) ; return $ copy ; } return false ; } | Install ruleset in base path . |
8,992 | protected function setPaths ( ) { $ pathPackage = realpath ( __DIR__ . '/../../../../' ) ; $ pathBase = realpath ( base_path ( ) ) ; $ this -> pathCli = $ pathBase . '/vendor/bin/' . $ this :: CLI_TOOL ; if ( ! file_exists ( $ this -> pathCli ) ) { $ this -> pathCli = $ pathPackage . '/vendor/bin/' . $ this :: CLI_TOOL... | Set paths to executable and ruleset . |
8,993 | public function match ( $ query ) { $ ruleParts = explode ( '/' , $ this -> rule ) ; $ queryParts = explode ( '/' , $ query ) ; $ ruleCount = count ( $ ruleParts ) ; $ match = false ; for ( $ i = 0 ; $ i < $ ruleCount ; $ i ++ ) { $ rp = $ ruleParts [ $ i ] ; $ qp = isset ( $ queryParts [ $ i ] ) ? $ queryParts [ $ i ]... | Check if the route matches a query |
8,994 | protected function add ( array $ image_size_item ) { array_walk ( $ image_size_item , function ( array $ args , string $ name ) { add_image_size ( $ name , $ args [ 0 ] , $ args [ 1 ] , isset ( $ args [ 2 ] ) ? $ args [ 2 ] : false ) ; } ) ; } | Add image sizes for given keys and values . |
8,995 | public function sendRequest ( RequestContext $ requestContext ) : ResponseContextAbstract { $ curlHandle = $ this -> curlHelper -> getRequestHandle ( $ requestContext ) ; $ responseContext = $ requestContext -> getResponseContextObject ( ) ; list ( 'httpStatus' => $ status , 'response' => $ content , 'headers' => $ hea... | Send previously prepared request |
8,996 | protected function loadEntities ( $ entityManager ) { foreach ( glob ( $ this -> getPath ( ) . '/Entity/*.php' ) as $ file ) { $ class = \ Asgard \ Common \ Tools :: loadClassFile ( $ file ) ; if ( is_subclass_of ( $ class , 'Asgard\Entity\Entity' ) ) $ entityManager -> get ( $ class ) ; } } | Load bundle s entities . |
8,997 | protected function loadCommands ( $ console ) { if ( file_exists ( $ this -> getPath ( ) . '/Command/' ) ) { foreach ( glob ( $ this -> getPath ( ) . '/Command/*.php' ) as $ filename ) { $ class = \ Asgard \ Common \ Tools :: loadClassFile ( $ filename ) ; if ( is_subclass_of ( $ class , 'Symfony\Component\Console\Comm... | Load bundle s commands . |
8,998 | protected function loadHooks ( ) { $ hooks = [ ] ; if ( file_exists ( $ this -> getPath ( ) . '/Hook/' ) ) { foreach ( glob ( $ this -> getPath ( ) . '/Hook/*.php' ) as $ filename ) { $ class = \ Asgard \ Common \ Tools :: loadClassFile ( $ filename ) ; if ( is_subclass_of ( $ class , 'Asgard\Hook\HookContainer' ) ) $ ... | Return bundle s hooks . |
8,999 | protected function loadControllers ( ) { $ routes = [ ] ; if ( file_exists ( $ this -> getPath ( ) . '/Controller/' ) ) { foreach ( glob ( $ this -> getPath ( ) . '/Controller/*.php' ) as $ filename ) { $ class = \ Asgard \ Common \ Tools :: loadClassFile ( $ filename ) ; if ( is_subclass_of ( $ class , 'Asgard\Http\Co... | Return bundle s controller routes . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.