Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Logo Class Reference
Inheritance diagram for Logo:
Template AbstractBlock DataObject BlockInterface

Public Member Functions

 __construct (\Magento\Framework\View\Element\Template\Context $context, \Magento\MediaStorage\Helper\File\Storage\Database $fileStorageHelper, array $data=[])
 
 isHomePage ()
 
 getLogoSrc ()
 
 getLogoAlt ()
 
 getLogoWidth ()
 
 getLogoHeight ()
 
- Public Member Functions inherited from Template
 __construct (Template\Context $context, array $data=[])
 
 setTemplateContext ($templateContext)
 
 getTemplate ()
 
 setTemplate ($template)
 
 getTemplateFile ($template=null)
 
 getArea ()
 
 assign ($key, $value=null)
 
 fetchView ($fileName)
 
 getBaseUrl ()
 
 getObjectData (\Magento\Framework\DataObject $object, $key)
 
 getCacheKeyInfo ()
 
- Public Member Functions inherited from AbstractBlock
 __construct (\Magento\Framework\View\Element\Context $context, array $data=[])
 
 getJsLayout ()
 
 getRequest ()
 
 getParentBlock ()
 
 setLayout (\Magento\Framework\View\LayoutInterface $layout)
 
 getLayout ()
 
 setNameInLayout ($name)
 
 getChildNames ()
 
 setAttribute ($name, $value=null)
 
 setChild ($alias, $block)
 
 addChild ($alias, $block, $data=[])
 
 unsetChild ($alias)
 
 unsetCallChild ($alias, $callback, $result, $params)
 
 unsetChildren ()
 
 getChildBlock ($alias)
 
 getChildHtml ($alias='', $useCache=true)
 
 getChildChildHtml ($alias, $childChildAlias='', $useCache=true)
 
 getBlockHtml ($name)
 
 insert ($element, $siblingName=0, $after=true, $alias='')
 
 append ($element, $alias='')
 
 getGroupChildNames ($groupName)
 
 getChildData ($alias, $key='')
 
 getUiId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getJsId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getUrl ($route='', $params=[])
 
 getViewFileUrl ($fileId, array $params=[])
 
 formatDate ( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)
 
 formatTime ( $time=null, $format=\IntlDateFormatter::SHORT, $showDate=false)
 
 getModuleName ()
 
 escapeHtml ($data, $allowedTags=null)
 
 escapeJs ($string)
 
 escapeHtmlAttr ($string, $escapeSingleQuote=true)
 
 escapeCss ($string)
 
 stripTags ($data, $allowableTags=null, $allowHtmlEntities=false)
 
 escapeUrl ($string)
 
 escapeXssInUrl ($data)
 
 escapeQuote ($data, $addSlashes=false)
 
 escapeJsQuote ($data, $quote='\'')
 
 getNameInLayout ()
 
 getCacheKeyInfo ()
 
 getCacheKey ()
 
 getVar ($name, $module=null)
 
 isScopePrivate ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
- Public Member Functions inherited from BlockInterface
 toHtml ()
 

Protected Member Functions

 _getLogoUrl ()
 
 _isFile ($filename)
 
- Protected Member Functions inherited from Template
 _construct ()
 
 _toHtml ()
 
 getRootDirectory ()
 
 getMediaDirectory ()
 
- Protected Member Functions inherited from AbstractBlock
 _construct ()
 
 _prepareLayout ()
 
 _beforeToHtml ()
 
 _afterToHtml ($html)
 
 _toHtml ()
 
 _getNotFoundUrl ($route='', $params=['_direct'=> 'core/index/notFound'])
 
 getCacheTags ()
 
 getCacheLifetime ()
 
 _loadCache ()
 
 _saveCache ($data)
 
 _getSidPlaceholder ($cacheKey=null)
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_template = 'Magento_Theme::html/header/logo.phtml'
 
 $_fileStorageHelper
 
- Protected Attributes inherited from Template
 $_viewVars = []
 
 $_baseUrl
 
 $_jsUrl
 
 $_allowSymlinks
 
 $_filesystem
 
 $_template
 
 $templateEnginePool
 
 $_storeManager
 
 $_appState
 
 $directory
 
 $templateContext
 
 $pageConfig
 
 $resolver
 
 $validator
 
- Protected Attributes inherited from AbstractBlock
 $_design
 
 $_session
 
 $_sidResolver
 
 $_nameInLayout
 
 $_layout
 
 $jsLayout = []
 
 $_request
 
 $_urlBuilder
 
 $_eventManager
 
 $_frontController
 
 $_assetRepo
 
 $_viewConfig
 
 $_cacheState
 
 $_logger
 
 $_escaper
 
 $filterManager
 
 $_localeDate
 
 $inlineTranslation
 
 $_isScopePrivate = false
 
 $_scopeConfig
 
 $_cache
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractBlock
static extractModuleName ($className)
 
- Data Fields inherited from Template
const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink'
 
- Data Fields inherited from AbstractBlock
const CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER
 
const CACHE_KEY_PREFIX = 'BLOCK_'
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Logo page header block

@api

Since
100.0.2

Definition at line 15 of file Logo.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\View\Element\Template\Context  $context,
\Magento\MediaStorage\Helper\File\Storage\Database  $fileStorageHelper,
array  $data = [] 
)
Parameters
\Magento\Framework\View\Element\Template\Context$context
\Magento\MediaStorage\Helper\File\Storage\Database$fileStorageHelper
array$data

Definition at line 34 of file Logo.php.

38  {
39  $this->_fileStorageHelper = $fileStorageHelper;
40  parent::__construct($context, $data);
41  }

Member Function Documentation

◆ _getLogoUrl()

_getLogoUrl ( )
protected

Retrieve logo image URL

Returns
string

Definition at line 121 of file Logo.php.

122  {
123  $folderName = \Magento\Config\Model\Config\Backend\Image\Logo::UPLOAD_DIR;
124  $storeLogoPath = $this->_scopeConfig->getValue(
125  'design/header/logo_src',
126  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
127  );
128  $path = $folderName . '/' . $storeLogoPath;
129  $logoUrl = $this->_urlBuilder
130  ->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]) . $path;
131 
132  if ($storeLogoPath !== null && $this->_isFile($path)) {
133  $url = $logoUrl;
134  } elseif ($this->getLogoFile()) {
135  $url = $this->getViewFileUrl($this->getLogoFile());
136  } else {
137  $url = $this->getViewFileUrl('images/logo.svg');
138  }
139  return $url;
140  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17

◆ _isFile()

_isFile (   $filename)
protected

If DB file storage is on - find there, otherwise - just file_exists

Parameters
string$filenamerelative path
Returns
bool

Definition at line 148 of file Logo.php.

149  {
150  if ($this->_fileStorageHelper->checkDbUsage() && !$this->getMediaDirectory()->isFile($filename)) {
151  $this->_fileStorageHelper->saveFileToFilesystem($filename);
152  }
153 
154  return $this->getMediaDirectory()->isFile($filename);
155  }

◆ getLogoAlt()

getLogoAlt ( )

Retrieve logo text

Returns
string

Definition at line 73 of file Logo.php.

74  {
75  if (empty($this->_data['logo_alt'])) {
76  $this->_data['logo_alt'] = $this->_scopeConfig->getValue(
77  'design/header/logo_alt',
78  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
79  );
80  }
81  return $this->_data['logo_alt'];
82  }

◆ getLogoHeight()

getLogoHeight ( )

Retrieve logo height

Returns
int

Definition at line 105 of file Logo.php.

106  {
107  if (empty($this->_data['logo_height'])) {
108  $this->_data['logo_height'] = $this->_scopeConfig->getValue(
109  'design/header/logo_height',
110  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
111  );
112  }
113  return (int)$this->_data['logo_height'] ? : (int)$this->getLogoImgHeight();
114  }

◆ getLogoSrc()

getLogoSrc ( )

Get logo image URL

Returns
string

Definition at line 60 of file Logo.php.

61  {
62  if (empty($this->_data['logo_src'])) {
63  $this->_data['logo_src'] = $this->_getLogoUrl();
64  }
65  return $this->_data['logo_src'];
66  }

◆ getLogoWidth()

getLogoWidth ( )

Retrieve logo width

Returns
int

Definition at line 89 of file Logo.php.

90  {
91  if (empty($this->_data['logo_width'])) {
92  $this->_data['logo_width'] = $this->_scopeConfig->getValue(
93  'design/header/logo_width',
94  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
95  );
96  }
97  return (int)$this->_data['logo_width'] ? : (int)$this->getLogoImgWidth();
98  }

◆ isHomePage()

isHomePage ( )

Check if current url is url for home page

Returns
bool

Definition at line 48 of file Logo.php.

49  {
50  $currentUrl = $this->getUrl('', ['_current' => true]);
51  $urlRewrite = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);
52  return $currentUrl == $urlRewrite;
53  }

Field Documentation

◆ $_fileStorageHelper

$_fileStorageHelper
protected

Definition at line 27 of file Logo.php.

◆ $_template

$_template = 'Magento_Theme::html/header/logo.phtml'
protected

Definition at line 22 of file Logo.php.


The documentation for this class was generated from the following file: