检查字段名称是否合法

@param $name

@throws LaravelSmsException
342981
protected static function validateFieldName($name)
    {
        $fields = self::getFields();
        if (!in_array($name, $fields)) {
            $names = implode(', ', $fields);
            throw new LaravelSmsException("Illegal field `$name`, the field name must be one of $names.");
        }
    }
658692
public function setName($name)
    {
        if (null !== $name) {
            Assert::string($name, 'The application name must be a string. Got: %s');
            Assert::notEmpty($name, 'The application name must not be empty.');
            Assert::regex($name, '~^[a-zA-Z0-9\-]+$~', 'The application name must contain letters, numbers and hyphens only. Did you mean to call setDisplayName()?');
        }

        $this->name = $name;

        return $this;
    }
844146
private function validate($name)
    {
        if (!is_string($name)) {
            throw new InvalidNameException('Migration name must be a string, got ' . gettype($name));
        }

        if (strlen($name) === 0) {
            throw new InvalidNameException('Migration name must not be empty');
        }

        $validCharsRegex = '/^[' . self::NAME_VALID_CHARS_REGEX . ']+$/';
        if (preg_match($validCharsRegex, $name) === 0) {
            $invalidChars = preg_replace('/[' . self::NAME_VALID_CHARS_REGEX . ']/', '', $name);
            throw new InvalidNameException('Migration name contains invalid characters: ' . $invalidChars);
        }

        if (strlen($name) > self::MAX_NAME_LENGTH) {
            throw new InvalidNameException(sprintf(
                'Migration name cannot exceed %d characters, is %d: %s',
                self::MAX_NAME_LENGTH,
                strlen($name),
                $name
            ));
        }
    }
899631
public function get($name)
    {
        $config = $this->manager->config;
        // 已加载
        if (isset($this->_instances[$name])) {
            return $this->_instances[$name];
        }
        // 未注册
        if (!isset($config[$name])) {
            throw new \Mix\Exception\ComponentException("Did not register this component: {$name}");
        }
        // 创建组件
        $object = Bean::newInstance($config[$name]['ref']);
        // 组件效验
        if (!($object instanceof ComponentInterface)) {
            throw new \Mix\Exception\ComponentException("This class is not a component: {$config[$name]['class']}");
        }
        // 装入容器
        $this->_instances[$name] = $object;
        // 返回
        return $this->_instances[$name];
    }
1345740
public static function register($name, Agent $agent)
    {
        if (!is_string($name) || $name == '') {
            throw new SmsException('代理器：' . $name . ' 无效！');
        }
        self::$agents[$name] = $agent;
    }
1211083
public static function Delete ($name) {
		static::Start();
		if (!static::IsSessionActive()) {
			throw CoreException::RaiseSystemError('セッションが開始されていないため、セッションを利用できません。');
		}
		if (is_array($name)) {
			$_SESSION = Arrays::RemoveLowest($_SESSION, $name);
		} else {
			unset($_SESSION[$name]);
		}
	}
91002
public function set_name( $name )
    {
        foreach($this->components as $c)
        {
            $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template);
        }
    }
648104
public function setBlockName($name)
    {
        if (!StringHelper::endsWith($name, 'Block')) {
            $name .= 'Block';
        }
        
        $this->_blockName = Inflector::camelize($name);
    }
281485
public function setName($name)
    {
        if ($this->getMultiValue() === true) {
            $name .= $this->getMultiValueSuffix();
        }

        return parent::setName($name);
    }
533746
public function setName($name)
    {
        if ($this->lock) {
            throw new Exception('Route cannot be modified');
        }

        if (empty($name)) {
            return $name;
        }

        //Add group name if any
        $groupName = implode('', Router::$groupsProps['name']);
        $this->name = $groupName . $name;

        //Register
        Router::getInstance()->registerNamedRoute($this);

        return $this;
    }
114449
public function setName($name)
  {
    if (ThrottlerHelper::validateName($name) && !$this->isActive()) {
      $this->name = $name;
      return true;
    }
    return false;
  }
756147
public function end($name)
    {
        $this->lastOpen = null;

        $this->opens[$name] = false;
        $last = array_pop($this->stacks);
        if ($last[0] != $name) {
            throw new BlockException($name, "is unexpected, expected {$last[0]}");
        }

        $content = ob_get_clean();
        if (!isset($this->hasChild[$name])) {
            $content = $this->_replace($content);
        }

        $pre = count($this->stacks) - 1;
        if ($pre > -1 && $this->opens[$this->stacks[$pre][0]]) {
            $this->hasChild[$this->stacks[$pre][0]] = true;
        }

        switch ($last[1]) {
            case 'replace' : // 默认
                break;
            case 'append' : // 追加
                $content = $this->parent($name) . $content;
                break;
            case 'prepend' : // 前面增加
                $content .= $this->parent($name);
                break;
            case 'hide' : // 不存在就隐藏
                if (!isset($this->blocks[$name])) {
                    $content = '';
                }
                break;
            default :
                throw new BlockException($name, 'undefined action type');
        }

        $this->blocks[$this->placeholder($name)] = $content;

        // 输出占位符
        if (isset($last[2])) {
            echo $last[2];
        }
    }
1144751
public function parseControllerName($name)
	{
		if (strpos($name, ':') === false) {
			throw new \Exception(sprintf('Unparsable controller name "%s", it should have at least one ":"', $name));
		}

		$parts = explode(':', $name);

		if (count($parts) == 2) {
			list($class, $action) = $parts;

			$action = $action.'Action';

			if (!class_exists($class)) {
				throw new \Exception(sprintf('Controller class "%s" not found', $class));
			}

			if (!method_exists($class, $action)) {
				throw new \Exception(sprintf('Controller method "%s" does not exist for controller class "%s"', $action, $class));
			}

			return array(
				'controller' => $class,
				'action' => $action
			);
		}

		if (count($parts) == 3) {
			list($package, $controller, $action) = $parts;

			$action = $action.'Action';

			$packageName = $this->resolvePackage($package);

			$parts = explode('\\', $packageName);

			array_pop($parts);

			$namespace = implode('\\', $parts);

			return array(
				'controller' => '\\'.$namespace.'\\Controller\\'.$controller.'Controller',
				'action' => $action
			);
		}

		throw new \Exception(sprintf('Too many chunks in your controller name (got "%s")', implode(', ', $parts)));
	}
1127456
public function setName($name)
    {
        $this->name = is_string($name) ? ucfirst($name) : $this->name;
    }
1011633
private function bakeController(string $name) : void
    {
        $this->pathFragment = 'Controller/';

        $this->bake($name, 'Controller/controller', ['name' => $name], 'Controller');
    }
683823
public function setName($name) {
        if ($this->frozen) throw new RuntimeException('Configuration of "'.get_class($this).'" is frozen');

        $this->validateName($name);
        $this->name = $name;

        if ($name === '') {
            $this->aliases = [];                                    // a default command cannot have aliases
        }
        else {
            $this->aliases = array_diff($this->aliases, [$name]);   // remove overlapping aliases
        }
        return $this;
    }
536043
private function actionDelete($name)
    {
        $forms = $this->plugin->getForms();
        $forms->delete($name);
        /** @var TAdminUI $page */
        $page = Eresus_Kernel::app()->getPage();
        HTTP::redirect($page->url());
    }