123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
-
-
- namespace Doctrine\DBAL\Schema;
-
- use Doctrine\DBAL\Platforms\AbstractPlatform;
-
-
- abstract class AbstractAsset
- {
-
-
- protected $_name;
-
- protected $_quoted = false;
-
-
-
- protected function _setName($name)
- {
- if ($this->isQuoted($name)) {
- $this->_quoted = true;
- $name = $this->trimQuotes($name);
- }
- $this->_name = $name;
- }
-
-
-
- protected function isQuoted($identifier)
- {
- return (isset($identifier[0]) && ($identifier[0] == '`' || $identifier[0] == '"'));
- }
-
-
-
- protected function trimQuotes($identifier)
- {
- return trim($identifier, '`"');
- }
-
-
-
- public function getName()
- {
- return $this->_name;
- }
-
-
-
- public function getQuotedName(AbstractPlatform $platform)
- {
- return ($this->_quoted) ? $platform->quoteIdentifier($this->_name) : $this->_name;
- }
-
-
-
- protected function _generateIdentifierName($columnNames, $prefix='', $maxSize=30)
- {
-
-
-
-
- $hash = implode("", array_map(function($column) {
- return dechex(crc32($column));
- }, $columnNames));
- return substr(strtoupper($prefix . "_" . $hash), 0, $maxSize);
- }
- }
|