idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
16,900 | public static function getComparator ( DataTablesMappingInterface $ mapping ) { if ( null === $ mapping -> getParent ( ) ) { return "LIKE" ; } switch ( $ mapping -> getParent ( ) -> getType ( ) ) { case DataTablesColumnInterface :: DATATABLES_TYPE_DATE : case DataTablesColumnInterface :: DATATABLES_TYPE_HTML_NUM : case DataTablesColumnInterface :: DATATABLES_TYPE_NUM : case DataTablesColumnInterface :: DATATABLES_TYPE_NUM_FMT : return "=" ; } return "LIKE" ; } | Get a comparator . |
16,901 | public static function getWhere ( DataTablesMappingInterface $ mapping ) { $ where = [ static :: getAlias ( $ mapping ) , static :: getComparator ( $ mapping ) , static :: getParam ( $ mapping ) , ] ; return implode ( " " , $ where ) ; } | Get a where . |
16,902 | public function deleteAction ( Request $ request , $ name , $ id ) { $ dtProvider = $ this -> getDataTablesProvider ( $ name ) ; try { $ entity = $ this -> getDataTablesEntityById ( $ dtProvider , $ id ) ; $ this -> dispatchDataTablesEvent ( DataTablesEvents :: DATATABLES_PRE_DELETE , [ $ entity ] ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> remove ( $ entity ) ; $ em -> flush ( ) ; $ this -> dispatchDataTablesEvent ( DataTablesEvents :: DATATABLES_POST_DELETE , [ $ entity ] ) ; $ output = $ this -> prepareActionResponse ( 200 , "DataTablesController.deleteAction.success" ) ; } catch ( Exception $ ex ) { $ output = $ this -> handleDataTablesException ( $ ex , "DataTablesController.deleteAction" ) ; } return $ this -> buildDataTablesResponse ( $ request , $ name , $ output ) ; } | Delete an existing entity . |
16,903 | public function editAction ( Request $ request , $ name , $ id , $ data , $ value ) { $ dtProvider = $ this -> getDataTablesProvider ( $ name ) ; $ dtEditor = $ this -> getDataTablesEditor ( $ dtProvider ) ; $ dtColumn = $ this -> getDataTablesColumn ( $ dtProvider , $ data ) ; try { $ entity = $ this -> getDataTablesEntityById ( $ dtProvider , $ id ) ; if ( true === $ request -> isMethod ( HTTPInterface :: HTTP_METHOD_POST ) ) { $ value = $ request -> request -> get ( "value" ) ; } $ this -> dispatchDataTablesEvent ( DataTablesEvents :: DATATABLES_PRE_EDIT , [ $ entity ] ) ; $ dtEditor -> editColumn ( $ dtColumn , $ entity , $ value ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; $ this -> dispatchDataTablesEvent ( DataTablesEvents :: DATATABLES_POST_EDIT , [ $ entity ] ) ; $ output = $ this -> prepareActionResponse ( 200 , "DataTablesController.editAction.success" ) ; } catch ( Exception $ ex ) { $ output = $ this -> handleDataTablesException ( $ ex , "DataTablesController.editAction" ) ; } return new JsonResponse ( $ output ) ; } | Edit an existing entity . |
16,904 | public function exportAction ( Request $ request , $ name ) { $ windows = DataTablesExportHelper :: isWindows ( $ request ) ; $ dtProvider = $ this -> getDataTablesProvider ( $ name ) ; $ dtExporter = $ this -> getDataTablesCSVExporter ( $ dtProvider ) ; $ repository = $ this -> getDataTablesRepository ( $ dtProvider ) ; $ filename = ( new DateTime ( ) ) -> format ( "Y.m.d-H.i.s" ) . "-" . $ dtProvider -> getName ( ) . ".csv" ; $ charset = true === $ windows ? "iso-8859-1" : "utf-8" ; $ response = new StreamedResponse ( ) ; $ response -> headers -> set ( "Content-Disposition" , "attachment; filename=\"" . $ filename . "\"" ) ; $ response -> headers -> set ( "Content-Type" , "text/csv; charset=" . $ charset ) ; $ response -> setCallback ( function ( ) use ( $ dtProvider , $ repository , $ dtExporter , $ windows ) { $ this -> exportDataTablesCallback ( $ dtProvider , $ repository , $ dtExporter , $ windows ) ; } ) ; $ response -> setStatusCode ( 200 ) ; return $ response ; } | Export all entities . |
16,905 | public function optionsAction ( $ name ) { $ dtProvider = $ this -> getDataTablesProvider ( $ name ) ; $ dtWrapper = $ this -> getDataTablesWrapper ( $ dtProvider ) ; $ dtOptions = DataTablesWrapperHelper :: getOptions ( $ dtWrapper ) ; return new JsonResponse ( $ dtOptions ) ; } | Options of a DataTables . |
16,906 | public function showAction ( $ name , $ id ) { $ dtProvider = $ this -> getDataTablesProvider ( $ name ) ; try { $ entity = $ this -> getDataTablesEntityById ( $ dtProvider , $ id ) ; $ this -> dispatchDataTablesEvent ( DataTablesEvents :: DATATABLES_PRE_SHOW , [ $ entity ] ) ; } catch ( EntityNotFoundException $ ex ) { $ this -> getLogger ( ) -> debug ( $ ex -> getMessage ( ) ) ; $ entity = [ ] ; } $ serializer = $ this -> getDataTablesSerializer ( ) ; return new Response ( $ serializer -> serialize ( $ entity , "json" ) , 200 , [ "Content-type" => "application/json" ] ) ; } | Show an existing entity . |
16,907 | public function loadPsr4 ( ) { $ data = $ this -> getData ( ) ; if ( isset ( $ data [ 'always' ] ) ) { $ this -> loadPsr4Group ( $ data [ 'always' ] ) ; } if ( is_admin ( ) && isset ( $ data [ 'admin' ] ) ) { $ this -> loadPsr4Group ( $ data [ 'admin' ] ) ; } if ( ! is_admin ( ) && isset ( $ data [ 'frontend' ] ) ) { $ this -> loadPsr4Group ( $ data [ 'frontend' ] ) ; } } | Autoload all the classes inside the PSR4 sections for our groups |
16,908 | public function instantiateClasses ( ) { $ data = $ this -> getData ( ) ; if ( isset ( $ data [ 'always' ] ) ) { $ this -> instantiateGroup ( $ data [ 'always' ] ) ; } if ( is_admin ( ) && isset ( $ data [ 'admin' ] ) ) { $ this -> instantiateGroup ( $ data [ 'admin' ] ) ; } if ( ! is_admin ( ) && isset ( $ data [ 'frontend' ] ) ) { $ this -> instantiateGroup ( $ data [ 'frontend' ] ) ; } } | Automatically instanciate all the classes inside the instanciate sections for our groups |
16,909 | private function loadPsr4Group ( $ group ) { if ( ! isset ( $ group [ 'psr4' ] ) ) { return ; } foreach ( $ group [ 'psr4' ] as $ prefix => $ paths ) { $ this -> objectRegistry -> addPsr4 ( $ prefix , $ paths ) ; } } | Autoload the classes for a group |
16,910 | private function instantiateGroup ( $ group ) { if ( ! isset ( $ group [ 'instantiate' ] ) ) { return ; } foreach ( $ group [ 'instantiate' ] as $ nickname => $ className ) { $ this -> objectRegistry -> register ( $ nickname , new $ className ( ) ) ; } } | Instantiate the classes for a group |
16,911 | private function createUser ( array $ user ) { $ this -> fields = [ 'id' => $ this -> getValue ( 'id' , $ user ) , 'name' => $ this -> getValue ( 'name' , $ user ) , 'username' => $ this -> getValue ( 'username' , $ user ) , 'description' => $ this -> getValue ( 'description' , $ user ) , 'location' => $ this -> getValue ( 'location' , $ user ) , 'url' => $ this -> getValue ( 'url' , $ user ) , 'followers_count' => $ this -> getValue ( 'followers_count' , $ user ) , 'friends_count' => $ this -> getValue ( 'friends_count' , $ user ) , 'favourites_count' => $ this -> getValue ( 'favourites_count' , $ user ) , 'listed_count' => $ this -> getValue ( 'listed_count' , $ user ) , 'created_at' => $ this -> getValue ( 'created_at' , $ user ) ] ; } | Set most used user properties |
16,912 | public function configureKirki ( ) { self :: $ OPTIONS_DEFAULTS [ 'logo_image' ] = Urls :: assets ( 'images/admin/customizer.png' ) ; self :: $ OPTIONS_DEFAULTS [ 'url_path' ] = Urls :: baobabFramework ( 'vendor/aristath/kirki/' ) ; self :: $ OPTIONS_DEFAULTS [ 'description' ] = Strings :: translate ( 'This is the theme description' ) ; $ data = $ this -> getData ( ) ; return array_merge ( self :: $ OPTIONS_DEFAULTS , $ data [ 'options' ] ) ; } | Configure the Kirki library |
16,913 | public function registerControls ( $ controls ) { $ data = $ this -> getData ( ) ; $ customControls = $ data [ 'controls' ] ; foreach ( $ customControls as & $ c ) { $ c [ 'label' ] = $ this -> translateValueIfKeyExists ( $ c , 'label' ) ; $ c [ 'description' ] = $ this -> translateValueIfKeyExists ( $ c , 'description' ) ; $ c [ 'default' ] = $ this -> translateValueIfKeyExists ( $ c , 'default' ) ; $ c [ 'help' ] = $ this -> translateValueIfKeyExists ( $ c , 'help' ) ; if ( isset ( $ c [ 'choices' ] ) ) { foreach ( $ c [ 'choices' ] as $ id => $ label ) { if ( isset ( $ label ) ) { $ c [ 'choices' ] [ $ id ] = Strings :: translate ( $ label ) ; } } } } return array_merge ( $ controls , $ customControls ) ; } | Register the controls in the various panels and sections |
16,914 | public function createPanels ( $ wp_customize ) { $ data = $ this -> getData ( ) ; $ defaultPanel = $ data [ 'options' ] [ 'default_panel' ] ; $ wp_customize -> add_panel ( $ defaultPanel [ 'id' ] , array ( 'priority' => 10 , 'title' => Strings :: translate ( $ defaultPanel [ 'title' ] ) , 'description' => '' ) ) ; $ existingSections = $ wp_customize -> sections ( ) ; foreach ( $ existingSections as $ sectionId => $ section ) { if ( empty ( $ section -> panel ) ) { $ section -> panel = $ defaultPanel [ 'id' ] ; } } $ panels = $ data [ 'panels' ] ; $ panelPriority = 1000 ; foreach ( $ panels as $ panelProps ) { if ( isset ( $ panelProps [ 'title' ] ) ) { $ panelId = 'panel-' . $ panelPriority ; $ wp_customize -> add_panel ( $ panelId , array ( 'priority' => $ panelPriority , 'title' => Strings :: translate ( $ panelProps [ 'title' ] ) , 'description' => Strings :: translate ( $ panelProps [ 'description' ] ) ) ) ; } else { $ panelId = $ defaultPanel [ 'id' ] ; } $ sectionPriority = 10 ; foreach ( $ panelProps [ 'sections' ] as $ sectionId => $ sectionProps ) { $ wp_customize -> add_section ( $ sectionId , array ( 'panel' => $ panelId , 'priority' => $ sectionPriority , 'title' => Strings :: translate ( $ sectionProps [ 'title' ] ) , 'description' => Strings :: translate ( $ sectionProps [ 'description' ] ) ) ) ; $ sectionPriority += 10 ; } $ panelPriority += 10 ; } return $ wp_customize ; } | Create all panels and sections |
16,915 | public function getTweetsFromUser ( $ username , $ count = 10 , $ cacheMinutes = 30 , $ returnEntities = true ) { $ count = $ this -> getVerifiedCount ( $ count , 1 , 200 ) ; $ endpoint = '/statuses/user_timeline.json' ; $ url = $ this -> urlHelper -> joinSlugs ( [ $ this -> baseUrl , $ this -> apiVersion , $ endpoint ] ) ; $ data = [ 'screen_name' => $ username , 'count' => $ count ] ; $ headers = [ 'Authorization' => 'Bearer ' . $ this -> requestAppAccessToken ( ) ] ; $ response = $ this -> courier -> get ( $ url , $ data , $ headers , $ cacheMinutes ) ; if ( $ returnEntities ) { $ tweets = $ response -> toArray ( ) ; $ response = $ this -> createTweetEntities ( $ tweets ) ; } return $ response ; } | Get tweets from a specific user |
16,916 | public function indexAction ( ) { $ em = $ this -> getDoctrine ( ) -> getEntityManager ( ) ; $ entities = $ em -> getRepository ( 'DMSLauncherBundle:PreUser' ) -> findAll ( ) ; return array ( 'entities' => $ entities ) ; } | Lists all PreUser entities . |
16,917 | public function showAction ( $ id ) { $ em = $ this -> getDoctrine ( ) -> getEntityManager ( ) ; $ entity = $ em -> getRepository ( 'DMSLauncherBundle:PreUser' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find PreUser entity.' ) ; } return array ( 'entity' => $ entity , 'referralCount' => $ em -> getRepository ( 'DMSLauncherBundle:PreUser' ) -> getReferralsCount ( $ entity -> getToken ( ) ) , ) ; } | Finds and displays a PreUser entity . |
16,918 | public function containers ( $ limit = 10000 , $ marker = '' ) { $ response = $ this -> api -> request ( 'GET' , '/' , [ 'query' => [ 'limit' => intval ( $ limit ) , 'marker' => $ marker , ] , ] ) ; if ( $ response -> getStatusCode ( ) !== 200 ) { throw new ApiRequestFailedException ( 'Unable to list containers.' , $ response -> getStatusCode ( ) ) ; } $ containers = json_decode ( $ response -> getBody ( ) , true ) ; return new Collection ( $ this -> transformContainers ( $ containers ) ) ; } | Available containers . |
16,919 | public function createContainer ( $ name , $ type = 'public' ) { if ( ! in_array ( $ type , [ 'public' , 'private' , 'gallery' ] ) ) { throw new InvalidArgumentException ( 'Unknown type "' . $ type . '" provided.' ) ; } $ response = $ this -> api -> request ( 'PUT' , '/' . trim ( $ name , '/' ) , [ 'headers' => [ 'X-Container-Meta-Type' => $ type , ] , ] ) ; switch ( $ response -> getStatusCode ( ) ) { case 201 : return $ this -> getContainer ( trim ( $ name , '/' ) ) ; case 202 : throw new ApiRequestFailedException ( 'Container "' . $ name . '" already exists.' ) ; default : throw new ApiRequestFailedException ( 'Unable to create container "' . $ name . '".' , $ response -> getStatusCode ( ) ) ; } } | Creates new container . |
16,920 | protected function transformContainers ( array $ items ) { if ( ! count ( $ items ) ) { return [ ] ; } $ containers = [ ] ; foreach ( $ items as $ item ) { $ container = new Container ( $ this -> api , $ this -> uploader , $ item [ 'name' ] , $ item ) ; $ containers [ $ container -> name ( ) ] = $ container ; } return $ containers ; } | Transforms containers response to Container objects . |
16,921 | protected function setupMigrations ( ) { $ migrations = realpath ( __DIR__ . '/../database/migrations' ) ; $ this -> publishes ( [ $ migrations => $ this -> app -> databasePath ( ) . '/migrations' , ] ) ; } | Setup the Migrations . |
16,922 | protected function setupSeeds ( ) { $ seeds = realpath ( __DIR__ . '/../database/seeds' ) ; $ this -> publishes ( [ $ seeds => $ this -> app -> databasePath ( ) . '/seeds' , ] ) ; } | Setup the Seeds . |
16,923 | public function getMailer ( ) { if ( $ this -> isTestMode ) { $ className = \ Tx_Oelib_EmailCollector :: class ; } else { $ className = \ Tx_Oelib_RealMailer :: class ; } if ( ! is_object ( $ this -> mailer ) || ( get_class ( $ this -> mailer ) !== $ className ) ) { $ this -> mailer = GeneralUtility :: makeInstance ( $ className ) ; } return $ this -> mailer ; } | Retrieves the singleton mailer instance . Depending on the mode this instance is either an e - mail collector or a real mailer . |
16,924 | protected function requestAppAccessToken ( ) { $ credentials = $ this -> authHelper -> generateAppCredentials ( $ this -> apiKey , $ this -> apiSecret ) ; $ endpoint = '/oauth2/token' ; $ url = $ this -> urlHelper -> joinSlugs ( [ $ this -> baseUrl , $ endpoint ] ) ; $ data = [ 'grant_type' => 'client_credentials' ] ; $ headers = [ 'Authorization' => 'Basic ' . $ credentials , 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' ] ; $ response = $ this -> courier -> post ( $ url , $ data , $ headers ) -> toArray ( ) ; return $ response [ 'access_token' ] ; } | Request an app access token |
16,925 | protected function getVerifiedCount ( $ count , $ min = 1 , $ max = 100 ) { settype ( $ count , "integer" ) ; settype ( $ min , "integer" ) ; settype ( $ max , "integer" ) ; if ( $ min > $ max ) $ min = $ max ; if ( $ count < $ min ) { $ count = $ min ; } elseif ( $ count > $ max ) { $ count = $ max ; } return $ count ; } | Verify that the count parameter is in range |
16,926 | protected function createTweetEntities ( $ tweets ) { $ entities = [ ] ; foreach ( $ tweets as $ tweet ) { $ user = $ this -> twitterFactory -> createUser ( $ tweet [ 'user' ] ) ; $ entities [ ] = $ this -> twitterFactory -> createTweet ( $ tweet , $ user ) ; } return $ entities ; } | Create Tweet Entities |
16,927 | private function registerConfigurator ( ) { $ this -> app -> bind ( 'CodeZero\Twitter\Twitter' , function ( $ app ) { $ config = $ app [ 'config' ] -> has ( "twitter" ) ? $ app [ 'config' ] -> get ( "twitter" ) : $ app [ 'config' ] -> get ( "twitter::config" ) ; $ configurator = new \ CodeZero \ Configurator \ DefaultConfigurator ( ) ; $ courier = $ app -> make ( 'CodeZero\Twitter\TwitterCourier' ) ; $ authHelper = new \ CodeZero \ Twitter \ AuthHelper ( ) ; $ urlHelper = new \ CodeZero \ Utilities \ UrlHelper ( ) ; $ twitterFactory = new \ CodeZero \ Twitter \ TwitterFactory ( ) ; return new \ CodeZero \ Twitter \ Twitter ( $ config , $ configurator , $ courier , $ authHelper , $ urlHelper , $ twitterFactory ) ; } ) ; } | Register the configurator binding |
16,928 | public function registerAction ( ) { $ entity = new PreUser ( ) ; $ request = $ this -> getRequest ( ) ; $ form = $ this -> createForm ( new RegistrationForm ( ) , $ entity ) ; $ form -> bindRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ entity -> setRegisteredOn ( new \ DateTime ( 'now' ) ) ; $ em = $ this -> getDoctrine ( ) -> getEntityManager ( ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; $ entity -> setToken ( base_convert ( $ entity -> getId ( ) + 100000000 , 10 , 32 ) ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'launcher_done' , array ( 'token' => $ entity -> getToken ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) ) ; } | Creates a new PreUser entity . |
16,929 | public function commafy ( $ _ ) { if ( ! preg_match ( '/^\d{1,4}$/' , $ _ ) ) { return strrev ( ( string ) preg_replace ( '/(\d{3})(?=\d)(?!\d*\.)/' , '$1,' , strrev ( $ _ ) ) ) ; } else { return $ _ ; } } | Avoid grouping whole numbers between 0 to 9999 |
16,930 | public function addParam ( $ param , $ value ) { if ( ! $ this -> requestMethod -> hasParam ( $ param ) ) { throw new GiroCheckout_SDK_Exception_helper ( 'Failure: param "' . $ param . '" not valid or misspelled. Please check API Params List.' ) ; } if ( $ value instanceof GiroCheckout_SDK_Request_Cart ) { $ this -> params [ $ param ] = $ value -> getAllItems ( ) ; } else { $ this -> params [ $ param ] = $ value ; } return $ this ; } | Adds a key value pair to the params variable . Used to fill the request with data . |
16,931 | public function getResponseParam ( $ param ) { if ( isset ( $ this -> response [ $ param ] ) ) { return $ this -> response [ $ param ] ; } return null ; } | Returns the value from the response of the request . |
16,932 | public function redirectCustomerToPaymentProvider ( ) { if ( isset ( $ this -> response [ 'redirect' ] ) ) { header ( 'location:' . $ this -> response [ 'redirect' ] ) ; exit ; } elseif ( isset ( $ this -> response [ 'url' ] ) ) { header ( 'location:' . $ this -> response [ 'url' ] ) ; exit ; } } | modifies header to sent redirect location by GiroCheckout |
16,933 | public function getAvailableDevices ( ) { $ availableDevices = array ( ) ; $ rules = array_change_key_case ( $ this -> detector -> getRules ( ) ) ; foreach ( $ rules as $ device => $ rule ) { $ availableDevices [ $ device ] = static :: fromCamelCase ( $ device ) ; } return $ availableDevices ; } | Returns an array of all available devices |
16,934 | protected function loadInterfaceMetadata ( $ metadata ) { foreach ( $ metadata -> getReflectionClass ( ) -> getInterfaces ( ) as $ interface ) { $ metadata -> mergeRules ( $ this -> getClassMetadata ( $ interface -> getName ( ) ) ) ; } } | Checks if the object has interfaces and cascades parsing of annotatiosn to all the interfaces |
16,935 | public function hasParam ( $ paramName ) { if ( isset ( $ this -> paramFields [ $ paramName ] ) ) { return true ; } elseif ( 'sourceId' === $ paramName ) { return true ; } elseif ( 'userAgent' === $ paramName ) { return true ; } elseif ( 'orderId' === $ paramName ) { return true ; } elseif ( 'customerId' === $ paramName ) { return true ; } return false ; } | Checks if the param exists . Check is case sensitive . |
16,936 | public function getSubmitParams ( $ params ) { $ submitParams = array ( ) ; foreach ( $ this -> paramFields as $ k => $ mandatory ) { if ( isset ( $ params [ $ k ] ) && strlen ( $ params [ $ k ] ) > 0 ) { $ submitParams [ $ k ] = $ params [ $ k ] ; } elseif ( ( ! isset ( $ params [ $ k ] ) || strlen ( $ params [ $ k ] ) == 0 ) && $ mandatory ) { throw new \ Exception ( 'mandatory field ' . $ k . ' is unset or empty' ) ; } } return $ submitParams ; } | Returns all API call param fields in the correct order . Complains if a mandatory field is not present or empty . |
16,937 | public function checkResponse ( $ response ) { if ( ! is_array ( $ response ) ) { return FALSE ; } $ responseParams = array ( ) ; foreach ( $ this -> responseFields as $ k => $ mandatory ) { if ( isset ( $ response [ $ k ] ) ) { $ responseParams [ $ k ] = $ response [ $ k ] ; } elseif ( ! isset ( $ response [ $ k ] ) && $ mandatory ) { throw new \ Exception ( 'expected response field ' . $ k . ' is missing' ) ; } } return $ responseParams ; } | Returns all response param fields in the correct order . |
16,938 | public function checkNotification ( $ notify ) { if ( ! is_array ( $ notify ) ) { return FALSE ; } $ notifyParams = array ( ) ; foreach ( $ this -> notifyFields as $ k => $ mandatory ) { if ( isset ( $ notify [ $ k ] ) ) { $ notifyParams [ $ k ] = $ notify [ $ k ] ; } elseif ( ! isset ( $ notify [ $ k ] ) && $ mandatory ) { throw new \ Exception ( 'expected notification field ' . $ k . ' is missing' ) ; } } return $ notifyParams ; } | Returns all notify param fields in the correct order . |
16,939 | public function registerAssets ( ) { $ data = $ this -> getData ( ) ; $ manifest = $ this -> loadManifest ( ) ; if ( isset ( $ data [ 'styles' ] ) ) { foreach ( $ data [ 'styles' ] as $ handle => $ props ) { $ this -> handleStyleAction ( 'register' , $ handle , $ props , $ manifest ) ; } } if ( isset ( $ data [ 'scripts' ] ) ) { foreach ( $ data [ 'scripts' ] as $ handle => $ props ) { $ this -> handleScriptAction ( 'register' , $ handle , $ props , $ manifest ) ; } } } | Register the assets before we eventually enqueue them |
16,940 | public function enqueueAssets ( ) { $ data = $ this -> getData ( ) ; if ( isset ( $ data [ 'editor' ] ) ) { add_editor_style ( $ data [ 'editor' ] ) ; } if ( isset ( $ data [ 'styles' ] ) ) { foreach ( $ data [ 'styles' ] as $ handle => $ props ) { $ this -> handleStyleAction ( 'enqueue' , $ handle , $ props ) ; } } if ( isset ( $ data [ 'scripts' ] ) ) { foreach ( $ data [ 'scripts' ] as $ handle => $ props ) { $ this -> handleScriptAction ( 'enqueue' , $ handle , $ props ) ; } } } | Enqueue the assets |
16,941 | protected function loadManifest ( ) { $ manifestPath = Paths :: assets ( 'manifest.json' ) ; if ( file_exists ( $ manifestPath ) ) { return json_decode ( file_get_contents ( $ manifestPath ) , true ) ; } return null ; } | Read the manifest file that can be found at the root of the theme s asset folder . |
16,942 | protected function objectData ( $ key , $ default = null ) { if ( ! $ this -> dataLoaded ) { $ this -> loadContainerData ( ) ; } return isset ( $ this -> data [ $ key ] ) ? $ this -> data [ $ key ] : $ default ; } | Returns specific container data . |
16,943 | protected function loadContainerData ( ) { $ response = $ this -> api -> request ( 'HEAD' , $ this -> absolutePath ( ) ) ; if ( $ response -> getStatusCode ( ) !== 204 ) { throw new ApiRequestFailedException ( 'Container "' . $ this -> name ( ) . '" was not found.' ) ; } $ this -> dataLoaded = true ; $ this -> data = [ 'type' => $ response -> getHeaderLine ( 'X-Container-Meta-Type' ) , 'count' => intval ( $ response -> getHeaderLine ( 'X-Container-Object-Count' ) ) , 'bytes' => intval ( $ response -> getHeaderLine ( 'X-Container-Bytes-Used' ) ) , 'rx_bytes' => intval ( $ response -> getHeaderLine ( 'X-Received-Bytes' ) ) , 'tx_bytes' => intval ( $ response -> getHeaderLine ( 'X-Transfered-Bytes' ) ) , 'meta' => $ this -> extractMetaData ( $ response ) , ] ; } | Container data lazy loader . |
16,944 | public function jsonSerialize ( ) { return [ 'name' => $ this -> name ( ) , 'type' => $ this -> type ( ) , 'files_count' => $ this -> filesCount ( ) , 'size' => $ this -> size ( ) , 'uploaded_bytes' => $ this -> uploadedBytes ( ) , 'downloaded_bytes' => $ this -> downloadedBytes ( ) , ] ; } | JSON representation of container . |
16,945 | public function setType ( $ type ) { if ( $ this -> type ( ) === $ type ) { return $ type ; } try { $ this -> setMeta ( [ 'Type' => $ type ] ) ; } catch ( ApiRequestFailedException $ e ) { throw new ApiRequestFailedException ( 'Unable to set container type to "' . $ type . '".' , $ e -> getCode ( ) ) ; } return $ this -> data [ 'type' ] = $ type ; } | Updates container type . |
16,946 | public function createDir ( $ name ) { $ response = $ this -> api -> request ( 'PUT' , $ this -> absolutePath ( $ name ) , [ 'headers' => [ 'Content-Type' => 'application/directory' , ] , ] ) ; if ( $ response -> getStatusCode ( ) !== 201 ) { throw new ApiRequestFailedException ( 'Unable to create directory "' . $ name . '".' , $ response -> getStatusCode ( ) ) ; } return $ response -> getHeaderLine ( 'ETag' ) ; } | Creates new directory . |
16,947 | public function deleteDir ( $ name ) { $ response = $ this -> api -> request ( 'DELETE' , $ this -> absolutePath ( $ name ) ) ; if ( $ response -> getStatusCode ( ) !== 204 ) { throw new ApiRequestFailedException ( 'Unable to delete directory "' . $ name . '".' , $ response -> getStatusCode ( ) ) ; } return true ; } | Deletes directory . |
16,948 | public function uploadFromString ( $ path , $ contents , array $ params = [ ] , $ verifyChecksum = true ) { return $ this -> uploader -> upload ( $ this -> api , $ this -> absolutePath ( $ path ) , $ contents , $ params , $ verifyChecksum ) ; } | Uploads file contents from string . Returns ETag header value if upload was successful . |
16,949 | public function uploadFromStream ( $ path , $ resource , array $ params = [ ] ) { return $ this -> uploader -> upload ( $ this -> api , $ this -> absolutePath ( $ path ) , $ resource , $ params , false ) ; } | Uploads file from stream . Returns ETag header value if upload was successful . |
16,950 | public function delete ( ) { $ response = $ this -> api -> request ( 'DELETE' , $ this -> absolutePath ( ) ) ; switch ( $ response -> getStatusCode ( ) ) { case 204 : return ; case 404 : throw new ApiRequestFailedException ( 'Container "' . $ this -> name ( ) . '" was not found.' ) ; case 409 : throw new ApiRequestFailedException ( 'Container must be empty.' ) ; } } | Deletes container . Container must be empty in order to perform this operation . |
16,951 | public function getName ( ) { if ( $ this -> hasString ( 'name' ) ) { $ result = $ this -> getAsString ( 'name' ) ; } elseif ( $ this -> hasFirstName ( ) || $ this -> hasLastName ( ) ) { $ result = trim ( $ this -> getFirstName ( ) . ' ' . $ this -> getLastName ( ) ) ; } else { $ result = $ this -> getUserName ( ) ; } return $ result ; } | Gets this user s real name . |
16,952 | public function hasGroupMembership ( $ uidList ) { if ( $ uidList === '' ) { throw new \ InvalidArgumentException ( '$uidList must not be empty.' , 1331488635 ) ; } $ isMember = false ; foreach ( GeneralUtility :: trimExplode ( ',' , $ uidList , true ) as $ uid ) { if ( $ this -> getUserGroups ( ) -> hasUid ( $ uid ) ) { $ isMember = true ; break ; } } return $ isMember ; } | Checks whether this user is a member of at least one of the user groups provided as comma - separated UID list . |
16,953 | public function setGender ( $ genderKey ) { $ validGenderKeys = [ self :: GENDER_MALE , self :: GENDER_FEMALE , self :: GENDER_UNKNOWN ] ; if ( ! in_array ( $ genderKey , $ validGenderKeys , true ) ) { throw new \ InvalidArgumentException ( '$genderKey must be one of the predefined constants, but actually is: ' . $ genderKey , 1393329321 ) ; } $ this -> setAsInteger ( 'gender' , $ genderKey ) ; } | Sets the gender . |
16,954 | public function getAge ( ) { if ( ! $ this -> hasDateOfBirth ( ) ) { return 0 ; } $ currentTimestamp = $ GLOBALS [ 'EXEC_TIME' ] ; $ birthTimestamp = $ this -> getDateOfBirth ( ) ; $ currentYear = ( int ) strftime ( '%Y' , $ currentTimestamp ) ; $ currentMonth = ( int ) strftime ( '%m' , $ currentTimestamp ) ; $ currentDay = ( int ) strftime ( '%d' , $ currentTimestamp ) ; $ birthYear = ( int ) strftime ( '%Y' , $ birthTimestamp ) ; $ birthMonth = ( int ) strftime ( '%m' , $ birthTimestamp ) ; $ birthDay = ( int ) strftime ( '%d' , $ birthTimestamp ) ; $ age = $ currentYear - $ birthYear ; if ( $ currentMonth < $ birthMonth ) { $ age -- ; } elseif ( $ currentMonth === $ birthMonth ) { if ( $ currentDay < $ birthDay ) { $ age -- ; } } return $ age ; } | Returns this user s age in years . |
16,955 | public function getCountry ( ) { $ countryCode = $ this -> getAsString ( 'static_info_country' ) ; if ( $ countryCode === '' ) { return null ; } try { $ countryMapper = \ Tx_Oelib_MapperRegistry :: get ( \ Tx_Oelib_Mapper_Country :: class ) ; $ country = $ countryMapper -> findByIsoAlpha3Code ( $ countryCode ) ; } catch ( \ Tx_Oelib_Exception_NotFound $ exception ) { $ country = null ; } return $ country ; } | Returns the country of this user as \ Tx_Oelib_Model_Country . |
16,956 | public function setCountry ( \ Tx_Oelib_Model_Country $ country = null ) { $ countryCode = ( $ country !== null ) ? $ country -> getIsoAlpha3Code ( ) : '' ; $ this -> setAsString ( 'static_info_country' , $ countryCode ) ; } | Sets the country of this user . |
16,957 | public function search ( $ interval ) { if ( is_null ( $ this -> top_node ) ) { return array ( ) ; } $ result = $ this -> find_intervals ( $ interval ) ; $ result = array_values ( $ result ) ; usort ( $ result , function ( RangeInterface $ a , RangeInterface $ b ) { $ x = $ a -> getStart ( ) ; $ y = $ b -> getStart ( ) ; $ comparedValue = $ this -> compare ( $ x , $ y ) ; if ( $ comparedValue == 0 ) { $ x = $ a -> getEnd ( ) ; $ y = $ b -> getEnd ( ) ; $ comparedValue = $ this -> compare ( $ x , $ y ) ; } return $ comparedValue ; } ) ; return $ result ; } | Search for ranges that overlap the specified value or range . |
16,958 | public function post ( $ url , $ requestBody = null ) { $ posturl = $ this -> url . $ url ; return $ this -> restRequest ( $ posturl , 'POST' , $ requestBody ) ; } | Generic Post Request |
16,959 | public function run ( ) { $ this -> generator -> addRaw ( array ( 'location' => 'example.com' , 'last_modified' => '2013-01-28' , 'change_frequency' => 'weekly' , 'priority' => '0.65' ) ) ; $ this -> generator -> addRaw ( array ( 'location' => 'example.com/test' , 'last_modified' => '2013-12-28' , 'change_frequency' => 'weekly' , 'priority' => '0.95' ) ) ; $ this -> generator -> addRaw ( array ( 'location' => 'example.com/test/2' , 'last_modified' => '2013-12-25' , 'change_frequency' => 'weekly' , 'priority' => '0.99' ) ) ; return $ this -> generator -> generate ( ) ; } | Run generator commands |
16,960 | public function canBuild ( ) { $ configuration = $ this -> getEmailConfiguration ( ) ; $ emailAddress = ( string ) $ configuration [ 'defaultMailFromAddress' ] ; return \ filter_var ( $ emailAddress , FILTER_VALIDATE_EMAIL ) !== false ; } | Checks whether a valid email address has been set as defaultMailFromAddress . |
16,961 | protected function getCachedRelationCount ( $ propertyName ) { if ( array_key_exists ( $ propertyName , $ this -> cachedRelationCountsCount ) ) { return $ this -> cachedRelationCountsCount [ $ propertyName ] ; } $ this -> cachedRelationCountsCount [ $ propertyName ] = $ this -> getUncachedRelationCount ( $ propertyName ) ; return $ this -> cachedRelationCountsCount [ $ propertyName ] ; } | Retrieves and caches the relation count for the given property . |
16,962 | protected function getUncachedRelationCount ( $ propertyName ) { if ( $ this -> $ propertyName instanceof LazyObjectStorage ) { $ reflectionClass = new \ ReflectionClass ( LazyObjectStorage :: class ) ; $ reflectionProperty = $ reflectionClass -> getProperty ( 'fieldValue' ) ; $ reflectionProperty -> setAccessible ( true ) ; $ count = ( int ) $ reflectionProperty -> getValue ( $ this -> $ propertyName ) ; } else { $ count = $ this -> $ propertyName -> count ( ) ; } return $ count ; } | Retrieves the relation count for the given property . |
16,963 | public function getPageUid ( ) { switch ( $ this -> getCurrentSource ( ) ) { case self :: SOURCE_MANUAL : $ result = $ this -> storedPageUid ; break ; case self :: SOURCE_FRONT_END : $ result = ( int ) $ this -> getFrontEndController ( ) -> id ; break ; case self :: SOURCE_BACK_END : $ result = ( int ) GeneralUtility :: _GP ( 'id' ) ; break ; default : $ result = 0 ; } return $ result ; } | Returns the UID of the current page . |
16,964 | public function getCurrentSource ( ) { if ( $ this -> manualPageUidSource !== self :: SOURCE_AUTO ) { $ result = $ this -> manualPageUidSource ; } elseif ( $ this -> hasManualPageUid ( ) ) { $ result = self :: SOURCE_MANUAL ; } elseif ( $ this -> hasFrontEnd ( ) ) { $ result = self :: SOURCE_FRONT_END ; } elseif ( $ this -> hasBackEnd ( ) ) { $ result = self :: SOURCE_BACK_END ; } else { $ result = self :: NO_SOURCE_FOUND ; } return $ result ; } | Returns the current source for the page UID . |
16,965 | public static function pickView ( $ stack ) { $ viewRoot = trailingslashit ( Paths :: views ( ) ) ; foreach ( $ stack as $ id ) { $ innerPath = str_replace ( '.' , '/' , $ id ) ; $ innerPath .= '.blade.php' ; if ( file_exists ( $ viewRoot . $ innerPath ) ) return $ id ; } return null ; } | Pick the first view found in the stack |
16,966 | public static function mainPageTitle ( ) { if ( is_home ( ) ) { if ( get_option ( 'page_for_posts' , true ) ) { return get_the_title ( get_option ( 'page_for_posts' , true ) ) ; } else { return __ ( 'Latest Posts' , 'baobab' ) ; } } elseif ( is_archive ( ) ) { $ term = get_term_by ( 'slug' , get_query_var ( 'term' ) , get_query_var ( 'taxonomy' ) ) ; if ( $ term ) { return apply_filters ( 'single_term_title' , $ term -> name ) ; } elseif ( is_post_type_archive ( ) ) { return apply_filters ( 'the_title' , get_queried_object ( ) -> labels -> name ) ; } elseif ( is_day ( ) ) { return sprintf ( __ ( 'Daily Archives: %s' , 'baobab' ) , get_the_date ( ) ) ; } elseif ( is_month ( ) ) { return sprintf ( __ ( 'Monthly Archives: %s' , 'baobab' ) , get_the_date ( 'F Y' ) ) ; } elseif ( is_year ( ) ) { return sprintf ( __ ( 'Yearly Archives: %s' , 'baobab' ) , get_the_date ( 'Y' ) ) ; } elseif ( is_author ( ) ) { $ author = get_queried_object ( ) ; return sprintf ( __ ( 'Author Archives: %s' , 'baobab' ) , apply_filters ( 'the_author' , is_object ( $ author ) ? $ author -> display_name : null ) ) ; } else { return single_cat_title ( '' , false ) ; } } elseif ( is_search ( ) ) { return sprintf ( __ ( 'Search Results for %s' , 'baobab' ) , get_search_query ( ) ) ; } elseif ( is_404 ( ) ) { return __ ( 'Not Found' , 'baobab' ) ; } else { return get_the_title ( ) ; } } | You can use this to output a proper title for your page . This handles special cases such as archive page titles taxonomy archives etc . |
16,967 | protected function buildDataTablesCountExported ( DataTablesProviderInterface $ dtProvider ) { $ prefix = $ dtProvider -> getPrefix ( ) ; $ qb = $ this -> createQueryBuilder ( $ prefix ) -> select ( "COUNT(" . $ prefix . ")" ) ; return $ qb ; } | Build a query builder Count exported . |
16,968 | protected function buildDataTablesCountFiltered ( DataTablesWrapperInterface $ dtWrapper ) { $ prefix = $ dtWrapper -> getMapping ( ) -> getPrefix ( ) ; $ qb = $ this -> createQueryBuilder ( $ prefix ) -> select ( "COUNT(" . $ prefix . ")" ) ; DataTablesRepositoryHelper :: appendWhere ( $ qb , $ dtWrapper ) ; return $ qb ; } | Build a query builder Count filtered . |
16,969 | protected function buildDataTablesCountTotal ( DataTablesWrapperInterface $ dtWrapper ) { $ prefix = $ dtWrapper -> getMapping ( ) -> getPrefix ( ) ; $ qb = $ this -> createQueryBuilder ( $ prefix ) -> select ( "COUNT(" . $ prefix . ")" ) ; return $ qb ; } | Build a query builder Count total . |
16,970 | protected function buildDataTablesFindAll ( DataTablesWrapperInterface $ dtWrapper ) { $ prefix = $ dtWrapper -> getMapping ( ) -> getPrefix ( ) ; $ qb = $ this -> createQueryBuilder ( $ prefix ) -> setFirstResult ( $ dtWrapper -> getRequest ( ) -> getStart ( ) ) ; if ( 0 < $ dtWrapper -> getRequest ( ) -> getLength ( ) ) { $ qb -> setMaxResults ( $ dtWrapper -> getRequest ( ) -> getLength ( ) ) ; } DataTablesRepositoryHelper :: appendWhere ( $ qb , $ dtWrapper ) ; DataTablesRepositoryHelper :: appendOrder ( $ qb , $ dtWrapper ) ; return $ qb ; } | Build a query builder Find all . |
16,971 | public static function isWindows ( Request $ request ) { if ( false === $ request -> headers -> has ( "user-agent" ) ) { return false ; } $ dd = new DeviceDetector ( $ request -> headers -> get ( "user-agent" ) ) ; $ dd -> parse ( ) ; $ os = $ dd -> getOs ( "name" ) ; return 1 === preg_match ( "/Windows/" , $ os ) ; } | Determines if the operating system is windows . |
16,972 | public function generateNonceField ( $ action ) { $ nonceName = $ this -> namespace . '_' . $ action ; return wp_nonce_field ( md5 ( $ nonceName ) , $ nonceName , true , false ) ; } | Get the HTML hidden field to print in your form to protect it |
16,973 | protected function getCacheTagsAndLifetime ( ) { $ lifetime = null ; $ tags = array ( ) ; $ entriesMetadata = $ this -> contentCacheFrontend -> getAllMetadata ( ) ; foreach ( $ entriesMetadata as $ identifier => $ metadata ) { $ entryTags = isset ( $ metadata [ 'tags' ] ) ? $ metadata [ 'tags' ] : array ( ) ; $ entryLifetime = isset ( $ metadata [ 'lifetime' ] ) ? $ metadata [ 'lifetime' ] : null ; if ( $ entryLifetime !== null ) { if ( $ lifetime === null ) { $ lifetime = $ entryLifetime ; } else { $ lifetime = min ( $ lifetime , $ entryLifetime ) ; } } $ tags = array_unique ( array_merge ( $ tags , $ entryTags ) ) ; } return array ( $ tags , $ lifetime ) ; } | Get cache tags and lifetime from the cache metadata that was extracted by the special cache frontend |
16,974 | public function banAll ( $ domains = null , $ contentType = null ) { $ this -> cacheInvalidator -> invalidateRegex ( '.*' , $ contentType , $ domains ) ; $ this -> logger -> log ( sprintf ( 'Cleared all Varnish cache%s%s' , $ domains ? ' for domains "' . ( is_array ( $ domains ) ? implode ( ', ' , $ domains ) : $ domains ) . '"' : '' , $ contentType ? ' with content type "' . $ contentType . '"' : '' ) ) ; $ this -> execute ( ) ; } | Clear all cache in Varnish for a optionally given domain & content type . |
16,975 | public function banByTags ( array $ tags , $ domains = null ) { if ( count ( $ this -> settings [ 'ignoredCacheTags' ] ) > 0 ) { $ tags = array_diff ( $ tags , $ this -> settings [ 'ignoredCacheTags' ] ) ; } foreach ( $ tags as $ key => $ tag ) { $ tags [ $ key ] = strtr ( $ tag , '.:' , '_-' ) ; } if ( $ domains ) { $ this -> varnishProxyClient -> setDefaultBanHeader ( ProxyClient \ Varnish :: HTTP_HEADER_HOST , is_array ( $ domains ) ? '^(' . implode ( '|' , $ domains ) . ')$' : $ domains ) ; } $ this -> tagHandler -> invalidateTags ( $ tags ) ; if ( $ domains ) { $ this -> varnishProxyClient -> setDefaultBanHeader ( ProxyClient \ Varnish :: HTTP_HEADER_HOST , ProxyClient \ Varnish :: REGEX_MATCH_ALL ) ; } $ this -> logger -> log ( sprintf ( 'Cleared Varnish cache for tags "%s"%s' , implode ( ',' , $ tags ) , $ domains ? ' for domains "' . ( is_array ( $ domains ) ? implode ( ', ' , $ domains ) : $ domains ) . '"' : '' ) ) ; $ this -> execute ( ) ; } | Clear all cache in Varnish for given tags . |
16,976 | protected function addFallthroughRoute ( $ controller , $ uri ) { $ missing = $ this -> any ( $ uri . '/{_missing}' , $ controller . '@missingMethod' ) ; $ missing -> where ( '_missing' , '(.*)' ) ; } | Add a fallthrough route for a controller . |
16,977 | public static function select ( $ fields , $ tableNames , $ whereClause = '' , $ groupBy = '' , $ orderBy = '' , $ limit = '' ) { if ( $ tableNames === '' ) { throw new \ InvalidArgumentException ( 'The table names must not be empty.' , 1331488261 ) ; } if ( $ fields === '' ) { throw new \ InvalidArgumentException ( '$fields must not be empty.' , 1331488270 ) ; } self :: enableQueryLogging ( ) ; $ dbResult = self :: getDatabaseConnection ( ) -> exec_SELECTquery ( $ fields , $ tableNames , $ whereClause , $ groupBy , $ orderBy , $ limit ) ; if ( ! $ dbResult ) { throw new \ Tx_Oelib_Exception_Database ( ) ; } return $ dbResult ; } | Executes a SELECT query . |
16,978 | public static function selectSingle ( $ fields , $ tableNames , $ whereClause = '' , $ groupBy = '' , $ orderBy = '' , $ offset = 0 ) { $ result = self :: selectMultiple ( $ fields , $ tableNames , $ whereClause , $ groupBy , $ orderBy , $ offset . ',' . 1 ) ; if ( empty ( $ result ) ) { throw new \ Tx_Oelib_Exception_EmptyQueryResult ( ) ; } return $ result [ 0 ] ; } | Executes a SELECT query and returns the single result row as an associative array . |
16,979 | public static function selectMultiple ( $ fieldNames , $ tableNames , $ whereClause = '' , $ groupBy = '' , $ orderBy = '' , $ limit = '' ) { $ result = [ ] ; $ dbResult = self :: select ( $ fieldNames , $ tableNames , $ whereClause , $ groupBy , $ orderBy , $ limit ) ; $ databaseConnection = self :: getDatabaseConnection ( ) ; while ( $ recordData = $ databaseConnection -> sql_fetch_assoc ( $ dbResult ) ) { $ result [ ] = $ recordData ; } $ databaseConnection -> sql_free_result ( $ dbResult ) ; return $ result ; } | Executes a SELECT query and returns the result rows as a two - dimensional associative array . |
16,980 | public function generate ( ) { $ this -> loadWebmasterTags ( ) ; $ title = $ this -> getTitle ( ) ; $ description = $ this -> getDescription ( ) ; $ keywords = $ this -> getKeywords ( ) ; $ metatags = $ this -> metatags ; $ html = array ( ) ; $ html [ ] = "<title>$title</title>" ; $ html [ ] = sprintf ( '<meta name="description" itemprop="description" content="%s" />%s' , $ description , PHP_EOL ) ; if ( ! empty ( $ keywords ) ) { $ html [ ] = sprintf ( '<meta name="keywords" content="%s" />%s' , $ keywords , PHP_EOL ) ; } foreach ( $ metatags as $ key => $ value ) : $ name = $ value [ 0 ] ; $ content = $ value [ 1 ] ; $ html [ ] = sprintf ( '<meta %s="%s" content="%s" />%s' , $ name , $ key , $ content , PHP_EOL ) ; endforeach ; return implode ( PHP_EOL , $ html ) ; } | Render the meta tags . |
16,981 | public function fromObject ( MetaAware $ object ) { $ data = $ object -> getMetaData ( ) ; if ( array_key_exists ( 'title' , $ data ) ) { $ this -> setTitle ( $ data [ 'title' ] ) ; } if ( array_key_exists ( 'description' , $ data ) ) { $ this -> setDescription ( $ data [ 'description' ] ) ; } if ( array_key_exists ( 'keywords' , $ data ) ) { $ this -> setKeywords ( $ data [ 'keywords' ] ) ; } } | Use the meta data of a MetaAware object . |
16,982 | public function setTitle ( $ title ) { $ title = strip_tags ( $ title ) ; $ this -> title_session = $ title ; $ this -> title = $ title . $ this -> getDefault ( 'separator' ) . $ this -> getDefault ( 'title' ) ; } | Set the Meta title . |
16,983 | public function setDescription ( $ description ) { $ description = strip_tags ( $ description ) ; if ( mb_strlen ( $ description ) > 160 ) { $ description = mb_substr ( $ description , 0 , 160 ) ; } $ this -> description = $ description ; } | Set the Meta description . |
16,984 | public function getKeywords ( ) { $ keywords = $ this -> keywords ? : $ this -> getDefault ( 'keywords' ) ; return ( is_array ( $ keywords ) ) ? implode ( ', ' , $ keywords ) : $ keywords ; } | Get the Meta keywords . |
16,985 | public function loadWebmasterTags ( ) { foreach ( $ this -> webmaster as $ name => $ value ) : if ( ! empty ( $ value ) ) : $ meta = array_get ( self :: $ webmasterTags , $ name , $ name ) ; $ this -> addMeta ( $ meta , $ value ) ; endif ; endforeach ; } | Load Webmaster tags |
16,986 | public function getLastVisited ( $ locale = null , $ query = null ) { $ query = $ this -> determineLocaleAndQuery ( $ locale , $ query ) ; $ lastVisited = $ query -> orderBy ( 'created_at' , 'desc' ) -> first ( ) ; return $ lastVisited ? $ lastVisited -> created_at : null ; } | Returns the last visited date |
16,987 | public function getTotalVisitCount ( $ locale = null , $ query = null ) { $ query = $ this -> determineLocaleAndQuery ( $ locale , $ query ) ; return $ query -> count ( ) ; } | Gets the total visit count |
16,988 | public function getTodayCount ( $ locale = null , $ query = null ) { $ query = $ this -> determineLocaleAndQuery ( $ locale , $ query ) ; return $ query -> where ( 'created_at' , '>=' , Carbon :: today ( ) ) -> count ( ) ; } | Gets today s visit count |
16,989 | public function getCountInBetween ( Carbon $ from , Carbon $ until = null , $ locale = null , $ query = null , $ cacheKey = null ) { if ( is_null ( $ until ) ) { $ until = Carbon :: now ( ) ; } if ( ! is_null ( $ cacheKey ) ) { $ count = $ this -> getCachedCountBetween ( $ from , $ until , $ locale , $ cacheKey ) ; if ( ! is_null ( $ count ) ) { return $ count ; } } $ query = $ this -> determineLocaleAndQuery ( $ locale , $ query ) ; $ count = $ query -> whereBetween ( 'created_at' , [ $ from , $ until ] ) -> count ( ) ; $ this -> cacheCountBetween ( $ count , $ from , $ until , $ locale , $ cacheKey ) ; return $ count ; } | Gets visit count in between dates |
16,990 | protected function getCachedCountBetween ( Carbon $ from , Carbon $ until , $ locale , $ cacheKey ) { $ key = $ this -> makeBetweenCacheKey ( $ from , $ until , $ locale , $ cacheKey ) ; return $ this -> cache -> get ( $ key ) ; } | Gets the cached count if there is any |
16,991 | protected function cacheCountBetween ( $ count , Carbon $ from , Carbon $ until , $ locale , $ cacheKey ) { if ( $ cacheKey && ( $ until -> timestamp < Carbon :: now ( ) -> timestamp ) ) { $ key = $ this -> makeBetweenCacheKey ( $ from , $ until , $ locale , $ cacheKey ) ; $ this -> cache -> put ( $ key , $ count , 525600 ) ; } } | Caches count between if cacheKey is present |
16,992 | protected function makeBetweenCacheKey ( Carbon $ from , Carbon $ until , $ locale , $ cacheKey ) { $ key = 'tracker.between.' . $ cacheKey . '.' ; $ key .= ( is_null ( $ locale ) ? '' : $ locale . '.' ) ; return $ key . $ from -> timestamp . '-' . $ until -> timestamp ; } | Makes the cache key |
16,993 | public function getRelativeYearCount ( $ end = null , $ locale = null , $ query = null , $ cacheKey = null ) { if ( is_null ( $ end ) ) { $ end = Carbon :: today ( ) ; } return $ this -> getCountInBetween ( $ end -> copy ( ) -> subYear ( ) -> startOfDay ( ) , $ end -> endOfDay ( ) , $ locale , $ query , $ cacheKey ) ; } | Get relative year visit count |
16,994 | public function getRelativeMonthCount ( $ end = null , $ locale = null , $ query = null , $ cacheKey = null ) { if ( is_null ( $ end ) ) { $ end = Carbon :: today ( ) ; } return $ this -> getCountInBetween ( $ end -> copy ( ) -> subMonth ( ) -> addDay ( ) -> startOfDay ( ) , $ end -> endOfDay ( ) , $ locale , $ query , $ cacheKey ) ; } | Get relative month visit count |
16,995 | public function getRelativeWeekCount ( $ end = null , $ locale = null , $ query = null , $ cacheKey = null ) { if ( is_null ( $ end ) ) { $ end = Carbon :: today ( ) ; } return $ this -> getCountInBetween ( $ end -> copy ( ) -> subWeek ( ) -> addDay ( ) -> startOfDay ( ) , $ end -> endOfDay ( ) , $ locale , $ query , $ cacheKey ) ; } | Get relative week visit count |
16,996 | public function getRelativeDayCount ( $ end = null , $ locale = null , $ query = null , $ cacheKey = null ) { if ( is_null ( $ end ) ) { $ end = Carbon :: today ( ) ; } return $ this -> getCountInBetween ( $ end , $ end -> copy ( ) -> endOfDay ( ) , $ locale , $ query , $ cacheKey ) ; } | Get relative day visit count |
16,997 | public function getCountForDay ( Carbon $ day = null , $ locale = null , $ query = null , $ cacheKey = null ) { if ( is_null ( $ day ) ) { $ day = Carbon :: now ( ) ; } return $ this -> getCountInBetween ( $ day -> startOfDay ( ) , $ day -> copy ( ) -> endOfDay ( ) , $ locale , $ query , $ cacheKey ) ; } | Gets count for given day |
16,998 | public function getCountPerMonth ( Carbon $ from , Carbon $ until = null , $ locale = null , $ query = null , $ cacheKey = null ) { return $ this -> getCountPer ( 'Month' , $ from , $ until , $ locale , $ query , $ cacheKey ) ; } | Get count per month in between |
16,999 | protected function getCountPer ( $ span , Carbon $ from , Carbon $ until = null , $ locale = null , $ query = null , $ cacheKey = null ) { $ query = $ this -> determineLocaleAndQuery ( $ locale , $ query ) ; $ statistics = [ ] ; $ labels = [ ] ; if ( is_null ( $ until ) ) { $ until = Carbon :: now ( ) ; } $ until -> { 'startOf' . $ span } ( ) ; while ( $ until -> gt ( $ from ) ) { $ start = $ until -> copy ( ) ; $ end = $ until -> copy ( ) -> { 'endOf' . $ span } ( ) ; $ labels [ ] = $ until -> copy ( ) ; $ statistics [ ] = $ this -> getCountInBetween ( $ start , $ end , $ locale , clone $ query , $ cacheKey ) ; $ until -> { 'sub' . $ span } ( ) ; } return [ array_reverse ( $ statistics ) , array_reverse ( $ labels ) ] ; } | Gets count per timespan |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.