idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
41,700 | public function getBagInfoData ( $ key ) { $ this -> _ensureBagInfoData ( ) ; return array_key_exists ( $ key , $ this -> bagInfoData ) ? $ this -> bagInfoData [ $ key ] : null ; } | This returns the value for a key from bagInfoData . |
41,701 | private function _createExtendedBag ( ) { if ( $ this -> extended ) { $ hashEncoding = $ this -> getHashEncoding ( ) ; $ this -> tagManifest = new BagItManifest ( "{$this->bagDirectory}/tagmanifest-$hashEncoding.txt" , $ this -> bagDirectory . '/' , $ this -> tagFileEncoding ) ; $ fetchFile = $ this -> bagDirectory . '... | This creates the files for an extended bag . |
41,702 | private function _readBagInfo ( ) { try { $ lines = readLines ( $ this -> bagInfoFile , $ this -> tagFileEncoding ) ; $ this -> bagInfoData = BagIt_parseBagInfo ( $ lines ) ; } catch ( Exception $ exc ) { array_push ( $ this -> bagErrors , array ( 'baginfo' , 'Error reading bag info file.' ) ) ; } } | This reads the bag - info . txt file into an array dictionary . |
41,703 | private function _writeBagInfo ( ) { $ lines = array ( ) ; if ( count ( $ this -> bagInfoData ) ) { foreach ( $ this -> bagInfoData as $ label => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ v ) { $ lines [ ] = "$label: $v\n" ; } } else { $ lines [ ] = "$label: $value\n" ; } } } writeFileText ( $ th... | This writes the bag - info . txt file with the contents of bagInfoData . |
41,704 | private function _isCompressed ( ) { if ( is_dir ( $ this -> bag ) ) { return false ; } else { $ bag = strtolower ( $ this -> bag ) ; if ( endsWith ( $ bag , '.zip' ) ) { $ this -> bagCompression = 'zip' ; return true ; } else if ( endsWith ( $ bag , '.tar.gz' ) || endsWith ( $ bag , '.tgz' ) ) { $ this -> bagCompressi... | Tests if a bag is compressed |
41,705 | public function read ( $ fileName = null ) { $ this -> _resetFileName ( $ fileName ) ; $ manifest = array ( ) ; $ hashLen = ( $ this -> hashEncoding == 'sha1' ) ? 40 : 32 ; $ lines = readLines ( $ this -> fileName , $ this -> fileEncoding ) ; foreach ( $ lines as $ line ) { $ hash = trim ( substr ( $ line , 0 , $ hashL... | This reads the data from the file name . |
41,706 | public function update ( $ fileList ) { $ csums = array ( ) ; foreach ( $ fileList as $ file ) { if ( file_exists ( $ file ) ) { $ hash = $ this -> calculateHash ( $ file ) ; $ csums [ $ this -> _makeRelative ( $ file ) ] = $ hash ; } } $ this -> data = $ csums ; $ this -> write ( ) ; return $ csums ; } | This updates the data in the manifest from the files passed in . |
41,707 | public function write ( $ fileName = null ) { $ this -> _resetFileName ( $ fileName ) ; ksort ( $ this -> data ) ; $ output = array ( ) ; foreach ( $ this -> data as $ path => $ hash ) { array_push ( $ output , "$hash $path\n" ) ; } writeFileText ( $ this -> fileName , $ this -> fileEncoding , implode ( '' , $ output )... | This writes the data to the manifest file . |
41,708 | public function getHash ( $ fileName ) { if ( array_key_exists ( $ fileName , $ this -> data ) ) { return $ this -> data [ $ fileName ] ; } else if ( array_key_exists ( $ this -> _makeRelative ( $ fileName ) , $ this -> data ) ) { return $ this -> data [ $ this -> _makeRelative ( $ fileName ) ] ; } else { return null ;... | This returns the hash for a file . |
41,709 | public function setHashEncoding ( $ hashEncoding ) { $ this -> hashEncoding = $ hashEncoding ; $ fileName = preg_replace ( '/-\w+\.txt$/' , "-$hashEncoding.txt" , $ this -> fileName ) ; if ( $ fileName != $ this -> fileName ) { rename ( $ this -> fileName , $ fileName ) ; $ this -> fileName = $ fileName ; } } | This sets the hash encoding . |
41,710 | public function validate ( & $ errors ) { $ errLen = count ( $ errors ) ; if ( ! file_exists ( $ this -> fileName ) ) { $ basename = basename ( $ this -> fileName ) ; array_push ( $ errors , array ( $ basename , "$basename does not exist." ) ) ; return false ; } foreach ( $ this -> data as $ fileName => $ hash ) { $ fu... | This validates the data in the manifest . |
41,711 | private function _resetFileName ( $ fileName = null ) { if ( $ fileName === null ) { return $ this -> fileName ; } else { $ this -> hashEncoding = $ this -> _parseHashEncoding ( $ fileName ) ; $ this -> fileName = $ fileName ; return $ fileName ; } } | This returns the file name to use . |
41,712 | private function _makeRelative ( $ filename ) { $ rel = substr ( $ filename , strlen ( $ this -> pathPrefix ) ) ; if ( ! $ rel ) { return '' ; } else { return $ rel ; } } | This takes a file name and strips the prefix path from it . |
41,713 | public function read ( ) { $ lines = readLines ( $ this -> fileName , $ this -> fileEncoding ) ; $ fetch = array ( ) ; foreach ( $ lines as $ line ) { $ fields = preg_split ( '/\s+/' , $ line ) ; if ( count ( $ fields ) == 3 ) { array_push ( $ fetch , array ( 'url' => $ fields [ 0 ] , 'length' => $ fields [ 1 ] , 'file... | This reads the data from the fetch file and populates the data array . |
41,714 | public function write ( ) { $ lines = array ( ) ; foreach ( $ this -> data as $ fetch ) { $ data = array ( $ fetch [ 'url' ] , $ fetch [ 'length' ] , $ fetch [ 'filename' ] ) ; array_push ( $ lines , join ( ' ' , $ data ) . "\n" ) ; } if ( count ( $ lines ) == 0 ) { if ( file_exists ( $ this -> fileName ) ) { unlink ( ... | This writes the data to the fetch file . |
41,715 | public function add ( $ url , $ filename ) { array_push ( $ this -> data , array ( 'url' => $ url , 'length' => '-' , 'filename' => $ filename ) ) ; $ this -> write ( ) ; } | This adds an entry to the fetch data . |
41,716 | public function download ( ) { $ basedir = dirname ( $ this -> fileName ) ; foreach ( $ this -> data as $ fetch ) { $ filename = $ basedir . '/' . $ fetch [ 'filename' ] ; if ( ! file_exists ( $ filename ) ) { $ this -> _downloadFile ( $ fetch [ 'url' ] , $ filename ) ; } } } | This downloads the files in the fetch information that aren t on the file system . |
41,717 | private function _downloadFile ( $ url , $ filename ) { $ dirname = dirname ( $ filename ) ; if ( ! is_dir ( $ dirname ) ) { mkdir ( $ dirname , 0777 , true ) ; } saveUrl ( $ url , $ filename ) ; } | This downloads a single file . |
41,718 | public function naoCompareceu ( Request $ request , AtendimentoService $ atendimentoService , TranslatorInterface $ translator ) { $ usuario = $ this -> getUser ( ) ; $ unidade = $ usuario -> getLotacao ( ) -> getUnidade ( ) ; $ atual = $ atendimentoService -> atendimentoAndamento ( $ usuario -> getId ( ) , $ unidade )... | Marca o atendimento como nao compareceu . |
41,719 | public function encerrar ( Request $ request , AtendimentoService $ atendimentoService , TranslatorInterface $ translator ) { $ envelope = new Envelope ( ) ; $ data = json_decode ( $ request -> getContent ( ) ) ; $ usuario = $ this -> getUser ( ) ; $ unidade = $ usuario -> getLotacao ( ) -> getUnidade ( ) ; $ atual = $... | Marca o atendimento como encerrado . |
41,720 | public function redirecionar ( Request $ request , AtendimentoService $ atendimentoService , TranslatorInterface $ translator ) { $ envelope = new Envelope ( ) ; $ data = json_decode ( $ request -> getContent ( ) ) ; $ usuario = $ this -> getUser ( ) ; $ unidade = $ usuario -> getLotacao ( ) -> getUnidade ( ) ; $ servi... | Marca o atendimento como erro de triagem . E gera um novo atendimento para o servico informado . |
41,721 | private function sendRequest ( $ api_method , $ data , $ multisplit = NULL , $ multikey = NULL ) { $ responseBody = $ this -> httpRequest ( $ api_method , $ data ) ; return $ this -> parseAsciiResponse ( $ responseBody , $ multisplit , $ multikey ) ; } | Send a HTTP request to the API |
41,722 | public static function factory ( $ config = [ ] ) { $ clientConfig = self :: getClientConfig ( $ config ) ; $ guzzleClient = new Client ( $ clientConfig ) ; if ( isset ( $ config [ 'apiVersion' ] ) && $ config [ 'apiVersion' ] !== 'v8' ) { throw new \ Exception ( 'Only v8 is supported at this time' ) ; } $ description ... | Factory method to create a new TogglClient |
41,723 | public function updateField ( $ field ) { if ( ! $ field instanceof ObjectField ) { throw new FieldEditorException ( print_r ( $ field , true ) . " is not of type ObjectField" ) ; } foreach ( $ this -> _fields as $ column => $ fields ) { foreach ( $ fields as $ index => $ f ) { $ existing_field = $ f -> getField ( ) ; ... | Given an ObjectField find a matching one in this section to update |
41,724 | private function prepare ( ) { $ session = new Session ( ) ; $ session -> start ( ) ; $ request = Request :: createFromGlobals ( ) ; $ request -> setSession ( $ session ) ; $ this -> requestStack -> push ( $ request ) ; $ this -> tokenStorage -> setToken ( new AnonymousToken ( 'anonymous' , 'anonymous' , [ 'ROLE_ADMINI... | Prepares Request and Token for CLI environment required by RichTextConverter to render embeded content . Avoid The token storage contains no authentication token and Rendering a fragment can only be done when handling a Request exceptions . |
41,725 | private function getUser ( TokenInterface $ authenticationToken ) { $ user = $ authenticationToken -> getUser ( ) ; if ( is_string ( $ user ) ) { return $ user ; } elseif ( method_exists ( $ user , 'getAPIUser' ) ) { return $ user -> getAPIUser ( ) -> id ; } return $ authenticationToken -> getUsername ( ) ; } | Returns current username or ApiUser id . |
41,726 | private function validate ( array $ options ) { if ( array_key_exists ( 'mandatorId' , $ options ) ) { $ options [ 'mandatorId' ] = ( int ) $ options [ 'mandatorId' ] ; } list ( $ customerId , $ licenseKey ) = $ this -> siteAccessHelper -> getRecommendationServiceCredentials ( $ options [ 'mandatorId' ] , $ options [ '... | Validates required options . |
41,727 | private function getLanguages ( $ options ) { if ( ! empty ( $ options [ 'lang' ] ) ) { return Text :: getArrayFromString ( $ options [ 'lang' ] ) ; } return $ this -> siteAccessHelper -> getLanguages ( $ options [ 'mandatorId' ] , $ options [ 'siteaccess' ] ) ; } | Returns languages list . |
41,728 | private function generateFiles ( $ languages , $ chunkDir , array $ options , OutputInterface $ output ) { $ urls = array ( ) ; $ output -> writeln ( sprintf ( 'Exporting %s content types' , count ( $ options [ 'contentTypeIds' ] ) ) ) ; foreach ( $ options [ 'contentTypeIds' ] as $ contentTypeId ) { $ contentTypeCurre... | Generate export files . |
41,729 | private function countContentItemsByContentTypeId ( $ contentTypeId , $ options ) { $ criteria = $ this -> generateCriteria ( $ contentTypeId , $ options ) ; $ query = new Query ( ) ; $ query -> query = new Criterion \ LogicalAnd ( $ criteria ) ; $ query -> limit = 0 ; return $ this -> searchService -> findContent ( $ ... | Returns total amount of content based on ContentType ids . |
41,730 | private function generateCriteria ( $ contentTypeId , array $ options ) { $ criteria = array ( new Criterion \ ContentTypeId ( $ contentTypeId ) , ) ; if ( $ options [ 'path' ] ) { $ criteria [ ] = new Criterion \ Subtree ( $ options [ 'path' ] ) ; } if ( ! $ options [ 'hidden' ] ) { $ criteria [ ] = new Criterion \ Vi... | Generates criteria for search query . |
41,731 | private function generateSubtreeCriteria ( $ mandatorId = null , $ siteAccess = null ) { $ siteAccesses = $ this -> siteAccessHelper -> getSiteAccesses ( $ mandatorId , $ siteAccess ) ; $ subtreeCriteria = [ ] ; $ rootLocations = $ this -> siteAccessHelper -> getRootLocationsBySiteAccesses ( $ siteAccesses ) ; foreach ... | Generates Criterions based on mandatorId or requested siteAccess . |
41,732 | private function generateFile ( $ content , $ chunkPath , array $ options ) { $ data = new ContentData ( $ content , $ options ) ; $ this -> outputGenerator -> reset ( ) ; $ this -> outputGenerator -> startDocument ( $ data ) ; $ contents = array ( ) ; foreach ( $ data -> contents as $ contentTypes ) { foreach ( $ cont... | Generating export file . |
41,733 | private function isContentTypeExcluded ( Content $ content ) { $ contentType = $ this -> repository -> sudo ( function ( ) use ( $ content ) { $ contentType = $ this -> contentTypeService -> loadContentType ( $ content -> contentInfo -> contentTypeId ) ; return $ contentType ; } ) ; return ! in_array ( $ contentType ->... | Checks if content is excluded from supported content types . |
41,734 | protected function notify ( array $ events ) { $ this -> logger -> debug ( sprintf ( 'POST notification to Recommendation Service: %s' , json_encode ( $ events , true ) ) ) ; $ data = array ( 'json' => array ( 'transaction' => null , 'events' => $ events , ) , 'auth' => array ( $ this -> options [ 'customer-id' ] , $ t... | Notifies the Recommendation Service API of one or more repository events . |
41,735 | private function notifyGuzzle6 ( array $ data ) { $ response = $ this -> guzzle -> request ( 'POST' , $ this -> getNotificationEndpoint ( ) , $ data ) ; $ this -> logger -> debug ( sprintf ( 'Got %s from Recommendation Service notification POST (guzzle v6)' , $ response -> getStatusCode ( ) ) ) ; } | Notifies the Recommendation Service API using Guzzle 6 synchronously . |
41,736 | private function parseRequest ( Request $ request ) { $ query = $ request -> query ; $ path = $ query -> get ( 'path' ) ; $ hidden = ( int ) $ query -> get ( 'hidden' , 0 ) ; $ image = $ query -> get ( 'image' ) ; $ siteAccess = $ query -> get ( 'siteaccess' ) ; $ webHook = $ query -> get ( 'webHook' ) ; $ transaction ... | Parses the request values . |
41,737 | public function getRootLocationBySiteAccessName ( $ siteAccessName = null ) { return $ this -> configResolver -> getParameter ( 'content.tree_root.location_id' , null , $ siteAccessName ? : $ this -> siteAccess -> name ) ; } | Returns rootLocation by siteAccess name or by default siteAccess . |
41,738 | public function getRootLocationsBySiteAccesses ( array $ siteAccesses ) { $ rootLocations = [ ] ; foreach ( $ siteAccesses as $ siteAccess ) { $ rootLocationId = $ this -> getRootLocationBySiteAccessName ( $ siteAccess ) ; $ rootLocations [ $ rootLocationId ] = $ rootLocationId ; } return array_keys ( $ rootLocations )... | Returns list of rootLocations from siteAccess list . |
41,739 | public function getLanguages ( $ mandatorId = null , $ siteAccess = null ) { if ( $ mandatorId ) { $ languages = $ this -> getMainLanguagesBySiteAccesses ( $ this -> getSiteAccessesByMandatorId ( $ mandatorId ) ) ; } elseif ( $ siteAccess ) { $ languages = $ this -> configResolver -> getParameter ( 'languages' , '' , $... | Returns languages based on mandatorId or siteaccess . |
41,740 | private function isMandatorIdConfigured ( $ mandatorId ) { return in_array ( $ this -> defaultSiteAccessName , $ this -> siteAccessConfig ) && $ this -> siteAccessConfig [ $ this -> defaultSiteAccessName ] [ 'yoochoose' ] [ 'customer_id' ] == $ mandatorId ; } | Checks if mandatorId is configured with default siteAccess . |
41,741 | public function getSiteAccesses ( $ mandatorId = null , $ siteAccess = null ) { if ( $ mandatorId ) { $ siteAccesses = $ this -> getSiteaccessesByMandatorId ( $ mandatorId ) ; } elseif ( $ siteAccess ) { $ siteAccesses = array ( $ siteAccess ) ; } else { $ siteAccesses = array ( $ this -> siteAccess -> name ) ; } retur... | Returns siteAccesses based on mandatorId requested siteAccess or default SiteAccess . |
41,742 | public function getRecommendationServiceCredentials ( $ mandatorId = null , $ siteAccess = null ) { $ siteAccesses = $ this -> getSiteAccesses ( $ mandatorId , $ siteAccess ) ; $ siteAccess = end ( $ siteAccesses ) ; if ( $ siteAccess === self :: SYSTEM_DEFAULT_SITEACCESS_NAME ) { $ siteAccess = null ; } $ customerId =... | Returns Recommendation Service credentials based on current siteAccess or mandatorId . |
41,743 | private function getMainLanguagesBySiteAccesses ( array $ siteAccesses ) { $ languages = array ( ) ; foreach ( $ siteAccesses as $ siteAccess ) { $ languageList = $ this -> configResolver -> getParameter ( 'languages' , '' , $ siteAccess !== 'default' ? $ siteAccess : null ) ; $ mainLanguage = reset ( $ languageList ) ... | Returns main languages from siteAccess list . |
41,744 | public function onKernelRequest ( GetResponseEvent $ event ) { $ session = $ event -> getRequest ( ) -> getSession ( ) ; if ( $ session === null || ! $ session -> isStarted ( ) ) { return ; } if ( ! $ event -> getRequest ( ) -> cookies -> has ( 'yc-session-id' ) ) { $ event -> getRequest ( ) -> cookies -> set ( 'yc-ses... | Creates a backup of current sessionId in case of sessionId change we need this value to identify user on YooChoose side . Be aware that session is automatically destroyed when user logs off in this case the new sessionId will be set . This issue can be treated as a later improvement as it s not required by YooChoose to... |
41,745 | public function getMapping ( $ contentTypeIdentifier , $ fieldIdentifier ) { $ key = $ contentTypeIdentifier . '.' . $ fieldIdentifier ; if ( ! isset ( $ this -> fieldMappings [ $ key ] ) ) { return false ; } $ identifier = explode ( '.' , $ this -> fieldMappings [ $ key ] ) ; return array ( 'content' => $ identifier [... | Get related mapping for specified content and field . |
41,746 | private function getImageFieldIdentifier ( $ contentId , $ language , $ related = false ) { $ content = $ this -> contentService -> loadContent ( $ contentId ) ; $ contentType = $ this -> contentTypeService -> loadContentType ( $ content -> contentInfo -> contentTypeId ) ; $ fieldDefinitions = $ this -> getFieldDefinit... | Return identifier of a field of ezimage type . |
41,747 | private function getRelation ( Content $ content , $ field , $ language ) { $ fieldDefinitions = $ this -> getFieldDefinitionList ( ) ; $ fieldNames = array_flip ( $ fieldDefinitions ) ; $ isRelation = ( in_array ( 'ezobjectrelation' , $ fieldDefinitions ) && $ field == $ fieldNames [ 'ezobjectrelation' ] ) ; if ( $ is... | Checks if content has image relation field returns its ID if true . |
41,748 | public function getConfiguredFieldIdentifier ( $ fieldName , ContentType $ contentType ) { $ contentTypeName = $ contentType -> identifier ; if ( isset ( $ this -> parameters [ 'fieldIdentifiers' ] ) ) { $ fieldIdentifiers = $ this -> parameters [ 'fieldIdentifiers' ] ; if ( isset ( $ fieldIdentifiers [ $ fieldName ] )... | Returns field name . |
41,749 | public function setFieldDefinitionsList ( ContentType $ contentType ) { foreach ( $ contentType -> fieldDefinitions as $ fieldDef ) { $ this -> fieldDefIdentifiers [ $ fieldDef -> identifier ] = $ fieldDef -> fieldTypeIdentifier ; } } | Prepares an array with field type identifiers . |
41,750 | public function prepareContent ( $ data , ParameterBag $ options , OutputInterface $ output = null ) { if ( $ output === null ) { $ output = new NullOutput ( ) ; } $ content = array ( ) ; foreach ( $ data as $ contentTypeId => $ items ) { $ progress = new ProgressBar ( $ output , count ( $ items ) ) ; $ progress -> sta... | Prepare content array . |
41,751 | private function getAuthor ( ApiContent $ contentValue , ApiContentType $ contentType ) { $ author = $ contentValue -> getFieldValue ( $ this -> value -> getConfiguredFieldIdentifier ( 'author' , $ contentType ) ) ; if ( null === $ author ) { try { $ ownerId = empty ( $ contentValue -> contentInfo -> ownerId ) ? $ this... | Returns author of the content . |
41,752 | private function prepareFields ( ApiContentType $ contentType , $ fields = null ) { if ( $ fields !== null ) { if ( strpos ( $ fields , ',' ) !== false ) { return explode ( ',' , $ fields ) ; } return array ( $ fields ) ; } $ fields = array ( ) ; $ contentFields = $ contentType -> getFieldDefinitions ( ) ; foreach ( $ ... | Checks if fields are given if not - returns all of them . |
41,753 | public function trackUser ( Twig_Environment $ twigEnvironment , $ contentId ) { if ( ! in_array ( $ this -> getContentIdentifier ( $ contentId ) , $ this -> options [ 'includedContentTypes' ] ) ) { return '' ; } return $ twigEnvironment -> render ( 'EzSystemsRecommendationBundle::track_user.html.twig' , array ( 'conte... | Renders simple tracking snippet code . |
41,754 | public function showRecommendations ( Twig_Environment $ twigEnvironment , $ contentId , $ scenario , $ limit , $ contentType , $ template , array $ fields , array $ params = array ( ) ) { if ( empty ( $ fields ) ) { throw new InvalidArgumentException ( 'Missing recommendation fields, at least one field is required' ) ... | Renders recommendations snippet code . |
41,755 | protected function getFeedbackUrl ( $ outputContentTypeId ) { return sprintf ( '%s/api/%d/rendered/%s/%d/' , $ this -> options [ 'trackingEndPoint' ] , $ this -> options [ 'customerId' ] , $ this -> getCurrentUserId ( ) , $ outputContentTypeId ) ; } | Returns YooChoose feedback end - point address used to report that recommendations were successfully fetched and displayed . |
41,756 | private function getCurrentUserId ( ) { if ( $ this -> authorizationChecker -> isGranted ( 'IS_AUTHENTICATED_FULLY' ) || $ this -> authorizationChecker -> isGranted ( 'IS_AUTHENTICATED_REMEMBERED' ) ) { $ authenticationToken = $ this -> tokenStorage -> getToken ( ) ; $ user = $ authenticationToken -> getUser ( ) ; if (... | Returns logged - in userId or anonymous sessionId . |
41,757 | public function ezxmltext ( Field $ field ) { try { $ xml = $ this -> xmlHtml5Converter -> convert ( $ field -> value -> xml ) ; } catch ( LogicException $ e ) { $ xml = $ field -> value -> xml -> saveHTML ( ) ; } return '<![CDATA[' . $ xml . ']]>' ; } | Method for parsing ezxmltext field . |
41,758 | public function ezrichtext ( Field $ field ) { return '<![CDATA[' . $ this -> richHtml5Converter -> convert ( $ field -> value -> xml ) -> saveHTML ( ) . ']]>' ; } | Method for parsing ezrichtext field . |
41,759 | public function ezimage ( Field $ field , Content $ content , $ language , $ imageFieldIdentifier , $ options = [ ] ) { if ( ! isset ( $ field -> value -> id ) ) { return '' ; } $ variations = $ this -> configResolver -> getParameter ( 'image_variations' ) ; $ variation = 'original' ; if ( ( ! empty ( $ options [ 'imag... | Method for parsing ezimage field . |
41,760 | public function ezobjectrelation ( Field $ field , Content $ content , $ language , $ imageFieldIdentifier , $ options = [ ] ) { $ fields = $ content -> getFieldsByLanguage ( $ language ) ; foreach ( $ fields as $ type => $ field ) { if ( $ type == $ imageFieldIdentifier ) { return $ this -> ezimage ( $ field , $ conte... | Method for parsing ezobjectrelation field . For now related fields refer to images . |
41,761 | protected function prepareContentByContentTypeIds ( $ contentTypeIds , Request $ request ) { $ options = $ this -> parseParameters ( $ request -> query , [ 'page_size' , 'page' , 'path' , 'hidden' , 'lang' , 'sa' , 'image' ] ) ; $ pageSize = ( int ) $ options -> get ( 'page_size' , self :: PAGE_SIZE ) ; $ page = ( int ... | Returns paged content based on ContentType ids . |
41,762 | public function load ( $ file ) { $ dir = $ this -> getDir ( ) ; if ( ! $ this -> filesystem -> exists ( $ dir . $ file ) ) { throw new NotFoundException ( 'File not found.' ) ; } return file_get_contents ( $ dir . $ file ) ; } | Load the content from file . |
41,763 | public function createChunkDir ( ) { $ directoryName = date ( 'Y/m/d/H/i/' , time ( ) ) ; $ dir = $ this -> getDir ( ) . $ directoryName ; if ( ! $ this -> filesystem -> exists ( $ dir ) ) { $ this -> filesystem -> mkdir ( $ dir , 0755 ) ; } return $ directoryName ; } | Generates directory for export files . |
41,764 | public function unlock ( ) { $ dir = $ this -> getDir ( ) ; if ( $ this -> filesystem -> exists ( $ dir . '.lock' ) ) { $ this -> filesystem -> remove ( $ dir . '.lock' ) ; } } | Unlock directory by deleting lock file . |
41,765 | public function secureDir ( $ chunkDir , $ credentials ) { $ dir = $ this -> getDir ( ) . $ chunkDir ; if ( $ credentials [ 'method' ] == 'none' ) { return array ( ) ; } elseif ( $ credentials [ 'method' ] == 'user' ) { return array ( 'login' => $ credentials [ 'login' ] , 'password' => $ credentials [ 'password' ] , )... | Securing the directory regarding the authentication method . |
41,766 | public static function getIdListFromString ( $ string ) { if ( filter_var ( $ string , FILTER_VALIDATE_INT ) !== false ) { return array ( $ string ) ; } return array_map ( function ( $ id ) { if ( false === filter_var ( $ id , FILTER_VALIDATE_INT ) ) { throw new InvalidArgumentException ( 'String should be a list of In... | Preparing array of integers based on comma separated integers in string or single integer in string . |
41,767 | public function search ( $ url , $ detailedAd = false ) { $ searchData = new SearchResultCrawler ( new Crawler ( ( string ) $ this -> client -> get ( $ url ) -> getBody ( ) ) , $ url ) ; $ url = new SearchResultUrlParser ( $ url , $ searchData -> getNbPages ( ) ) ; $ ads = ( $ detailedAd ) ? $ searchData -> getAds ( ) ... | retrieve the search result data from the given url |
41,768 | private function adByUrl ( $ url ) { $ content = $ this -> client -> get ( $ url ) -> getBody ( ) -> getContents ( ) ; $ adData = new AdCrawler ( new Crawler ( utf8_encode ( $ content ) ) , $ url ) ; return $ adData -> getAll ( ) ; } | Retrieve the ad s data from the given url |
41,769 | public function ad ( ) { if ( func_num_args ( ) === 1 ) { return call_user_func_array ( [ $ this , 'adByUrl' ] , func_get_args ( ) ) ; } if ( func_num_args ( ) === 2 ) { return call_user_func_array ( [ $ this , 'adById' ] , func_get_args ( ) ) ; } throw new \ InvalidArgumentException ( 'Bad number of argument' ) ; } | Dynamique method to retrive the data by url OR id and category |
41,770 | public static function toAscii ( $ string ) { $ alnumPattern = '/^[a-zA-Z0-9 ]+$/' ; $ string = iconv ( mb_detect_encoding ( $ string ) , 'ASCII//TRANSLIT' , $ string ) ; $ ret = array_map ( function ( $ chr ) use ( $ alnumPattern ) { if ( preg_match ( $ alnumPattern , $ chr ) ) { return $ chr ; } return '' ; } , str_s... | Replace accent and remove unknown chars |
41,771 | protected function getFieldValue ( Crawler $ node , $ defaultValue , $ callback = null , $ funcName = 'text' , $ funcParam = '' ) { if ( $ callback == null ) { $ callback = function ( $ value ) { return ( new DefaultSanitizer ) -> clean ( $ value ) ; } ; } if ( $ node -> count ( ) ) { return $ callback ( $ node -> $ fu... | Return the field s value |
41,772 | public function getNbAds ( ) { $ nbAds = $ this -> node -> filter ( 'a.tabsSwitch span.tabsSwitchNumbers' ) -> first ( ) ; if ( $ nbAds -> count ( ) ) { $ nbAds = preg_replace ( '/\s+/' , '' , $ nbAds -> text ( ) ) ; return ( int ) $ nbAds ; } return 0 ; } | Return the total number of ads of the search |
41,773 | public function getAds ( ) { $ ads = array ( ) ; $ this -> node -> filter ( '[itemtype="http://schema.org/Offer"]' ) -> each ( function ( $ node ) use ( & $ ads ) { $ ad = ( new SearchResultAdCrawler ( $ node , $ node -> filter ( 'a' ) -> attr ( 'href' ) ) ) -> getAll ( ) ; $ ads [ $ ad [ 'id' ] ] = $ ad ; } ) ; return... | Get an array containing the ads of the current result page |
41,774 | public function getAll ( ) { return array_merge ( [ 'id' => $ this -> getUrlParser ( ) -> getId ( ) , 'category' => $ this -> getUrlParser ( ) -> getCategory ( ) , ] , $ this -> getPictures ( ) , $ this -> getProperties ( ) , $ this -> getDescription ( ) ) ; } | Return a full ad information |
41,775 | public function getPictures ( Crawler $ node = null ) { $ node = $ node ? : $ this -> node ; $ images = [ 'images_thumbs' => [ ] , 'images' => [ ] , ] ; $ node -> filter ( '.adview_main script' ) -> each ( function ( Crawler $ crawler ) use ( & $ images ) { if ( preg_match_all ( '#//img.+.leboncoin.fr/.*\.jpg#' , $ cra... | Return an array with the Thumbs pictures url |
41,776 | public function getDescription ( Crawler $ node = null ) { $ node = $ node ? : $ this -> node ; return [ 'description' => $ this -> getFieldValue ( $ node -> filter ( "p[itemprop=description]" ) , null ) , ] ; } | Return the description |
41,777 | private function sanitize ( $ key , $ value ) { $ key = ( new KeySanitizer ) -> clean ( $ key ) ; if ( $ key == 'ville' ) { return [ 'ville' => ( new CitySanitizer ) -> clean ( $ value ) , 'cp' => ( new CpSanitizer ) -> clean ( $ value ) , ] ; } $ filteClass = 'Lbc\\Filter\\' . ucfirst ( $ key ) . 'Sanitizer' ; if ( ! ... | Transform the properties name into a snake_case string and sanitize the value |
41,778 | public function next ( ) { if ( ( int ) $ this -> current ( ) -> query -> getValue ( 'o' ) >= $ this -> nbPages ) { return null ; } return $ this -> getIndexUrl ( + 1 ) ; } | Return the next page URL or null if non . |
41,779 | public function getNav ( ) { return [ 'page' => ( int ) $ this -> current ( ) -> query -> getValue ( 'o' ) , 'links' => [ 'current' => ( string ) $ this -> current ( ) , 'previous' => ( string ) $ this -> previous ( ) , 'next' => ( string ) $ this -> next ( ) , ] ] ; } | Return a meta array containing the nav links and the page |
41,780 | public function getSearchArea ( ) { if ( $ this -> current ( ) -> path -> getSegment ( 3 ) === 'occasions' ) { return 'toute la france' ; } if ( $ this -> current ( ) -> path -> getSegment ( 3 ) === 'bonnes_affaires' ) { return 'regions voisines' ; } return $ this -> current ( ) -> path -> getSegment ( 2 ) ; } | Return the search area |
41,781 | public function getPrice ( ) { return $ this -> getFieldValue ( $ this -> node -> filter ( '*[itemprop=price]' ) , 0 , function ( $ value ) { return ( new PrixSanitizer ) -> clean ( $ value ) ; } ) ; } | Return the price |
41,782 | public function getThumb ( ) { $ image = $ this -> node -> filter ( '.item_imagePic .lazyload[data-imgsrc]' ) -> first ( ) ; if ( 0 === $ image -> count ( ) ) { return null ; } $ src = $ image -> attr ( 'data-imgsrc' ) ; return ( string ) Http :: createFromString ( $ src ) -> withScheme ( 'https' ) ; } | Return the thumb picture url |
41,783 | public function index ( ) { $ roles = $ this -> roleRepository -> createModel ( ) -> all ( ) ; $ userRoleIds = Sentinel :: getUser ( ) -> roles ( ) -> pluck ( 'id' ) ; return view ( 'Centaur::roles.index' ) -> with ( 'userRoleIds' , $ userRoleIds ) -> with ( 'roles' , $ roles ) ; } | Display a listing of the roles . |
41,784 | public function destroy ( Request $ request , $ id ) { $ user = $ this -> userRepository -> findById ( $ id ) ; if ( Sentinel :: getUser ( ) -> id == $ user -> id ) { $ message = "You cannot remove yourself!" ; if ( $ request -> expectsJson ( ) ) { return response ( ) -> json ( $ message , 422 ) ; } session ( ) -> flas... | Remove the specified user from storage . |
41,785 | public function postRequest ( Request $ request ) { $ result = $ this -> validate ( $ request , [ 'email' => 'required|email|max:255' ] ) ; $ user = Sentinel :: findUserByCredentials ( [ 'email' => $ request -> get ( 'email' ) ] ) ; if ( $ user ) { $ reminder = Reminder :: create ( $ user ) ; $ code = $ reminder -> cod... | Send a password reset link |
41,786 | public function getReset ( Request $ request , $ code ) { if ( ! $ this -> validatePasswordResetCode ( $ code ) ) { Session :: flash ( 'error' , 'Invalid or expired password reset code; please request a new link.' ) ; return redirect ( ) -> route ( 'dashboard' ) ; } return view ( 'Centaur::auth.password' ) -> with ( 'c... | Show the password reset form if the reset code is valid |
41,787 | public function postReset ( Request $ request , $ code ) { $ result = $ this -> validate ( $ request , [ 'password' => 'required|confirmed|min:6' , ] ) ; $ result = $ this -> authManager -> resetPassword ( $ code , $ request -> get ( 'password' ) ) ; if ( $ result -> isFailure ( ) ) { return $ result -> dispatch ( ) ; ... | Process a password reset form submission |
41,788 | public function has ( $ key ) { if ( $ key == 'message' ) { return ! empty ( $ this -> message ) ; } if ( $ key == 'exception' ) { return ! is_null ( $ this -> exception ) ; } return array_key_exists ( $ key , $ this -> payload ) ; } | Determine if a value exists within this object |
41,789 | public function remove ( $ key ) { if ( $ key == 'message' ) { $ this -> message = '' ; } if ( $ key == 'exception' ) { $ this -> exception = null ; } if ( array_key_exists ( $ key , $ this -> payload ) ) { unset ( $ this -> payload [ $ key ] ) ; } } | Unset a payload array key = > value |
41,790 | public function toArray ( ) { $ dispatch = [ ] ; $ dispatch [ 'status' ] = $ this -> statusCode ; if ( $ this -> hasMessage ( ) ) { $ dispatch [ 'message' ] = $ this -> message ; } if ( $ this -> hasPayload ( ) ) { $ dispatch = array_merge ( $ dispatch , $ this -> payload ) ; } return $ dispatch ; } | Convert the dispatch object to an array |
41,791 | private function registerArtisanCommands ( ) { $ this -> app -> singleton ( 'centaur.scaffold' , function ( $ app ) { return new CentaurScaffold ( $ app -> make ( 'files' ) ) ; } ) ; $ this -> commands ( 'centaur.scaffold' ) ; $ this -> app -> singleton ( 'centaur.spruce' , function ( $ app ) { return new CentaurSpruce... | Register the Artisan Commands |
41,792 | public function postLogin ( Request $ request ) { $ result = $ this -> validate ( $ request , [ 'email' => 'required' , 'password' => 'required' ] ) ; $ credentials = [ 'email' => trim ( $ request -> get ( 'email' ) ) , 'password' => $ request -> get ( 'password' ) , ] ; $ remember = ( bool ) $ request -> get ( 'rememb... | Handle a Login Request |
41,793 | public function getLogout ( Request $ request ) { $ result = $ this -> authManager -> logout ( null , null ) ; return $ result -> dispatch ( route ( 'dashboard' ) ) ; } | Handle a Logout Request |
41,794 | public function getActivate ( Request $ request , $ code ) { $ result = $ this -> authManager -> activate ( $ code ) ; if ( $ result -> isFailure ( ) ) { $ result -> setRedirectUrl ( route ( 'auth.login.form' ) ) ; return $ result -> dispatch ( ) ; } $ result -> setMessage ( 'Registration complete. You may now log in.... | Activate a user if they have provided the correct code |
41,795 | public function postResend ( Request $ request ) { $ result = $ this -> validate ( $ request , [ 'email' => 'required|email|max:255' ] ) ; $ user = Sentinel :: findUserByCredentials ( [ 'email' => $ request -> get ( 'email' ) ] ) ; if ( ! Activation :: completed ( $ user ) ) { $ activation = Activation :: create ( $ us... | Handle a resend activation request |
41,796 | public function authenticate ( $ credentials , $ remember = false , $ login = true ) { try { $ user = $ this -> sentinel -> authenticate ( $ credentials , $ remember , $ login ) ; } catch ( Exception $ e ) { return $ this -> returnException ( $ e ) ; } if ( $ user ) { $ message = request ( ) -> expectsJson ( ) ? $ this... | Attempt to authenticate a user |
41,797 | public function logout ( UserInterface $ user = null , $ everywhere = false ) { try { $ user = $ this -> sentinel -> logout ( $ user , $ everywhere ) ; } catch ( Exception $ e ) { return $ this -> returnException ( $ e ) ; } if ( ! $ this -> sentinel -> check ( ) ) { $ message = $ this -> translate ( 'user_logout' , 'Y... | Terminate a user s session . If no user is provided the currently active user will be signed out . |
41,798 | public function activate ( $ code ) { try { $ activation = $ this -> activations -> createModel ( ) -> newQuery ( ) -> where ( 'code' , $ code ) -> where ( 'completed' , false ) -> where ( 'created_at' , '>' , Carbon :: now ( ) -> subSeconds ( 259200 ) ) -> first ( ) ; if ( ! $ activation ) { $ message = $ this -> tran... | Activate a user based on the provided activation code |
41,799 | public function resetPassword ( $ code , $ password ) { try { $ reminder = $ this -> reminders -> createModel ( ) -> newQuery ( ) -> where ( 'code' , $ code ) -> where ( 'completed' , false ) -> where ( 'created_at' , '>' , Carbon :: now ( ) -> subSeconds ( 259200 ) ) -> first ( ) ; if ( ! $ reminder ) { $ message = $ ... | Attempt a password reset |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.