设置表单的class
@param $formClass
190598
protected function setFormClass($formClass){

        if (is_string($formClass)){
            $formClass = explode(" " , $formClass);
        }

        $this->formClass = $formClass;
    }
1319504
public function editItemClass()
    {
        $this->defaultData();

        $clazz = $this->getClass($this->getRequestParameter('id'));

        if($this->hasRequestParameter('property_mode')){
            $this->setSessionAttribute('property_mode', $this->getRequestParameter('property_mode'));
        }

        $myForm = $this->getClassForm($clazz, $this->getClassService()->getRootClass());

        if ($this->hasWriteAccess($clazz->getUri())) {
            if($myForm->isSubmited()){
                if($myForm->isValid()){
                    if($clazz instanceof core_kernel_classes_Resource){
                        $this->setData("selectNode", tao_helpers_Uri::encode($clazz->getUri()));
                    }
                    $this->setData('message', __('Class schema saved'));
                    $this->setData('reload', false);
                }
            }
        } else {
            $myForm->setActions(array());
        }
        $this->setData('formTitle', __('Manage item class schema'));
        $this->setData('myForm', $myForm->render());
        $this->setView('form.tpl', 'tao');
    }
1143460
public function setFormFieldType($formFieldType)
    {
        if (!is_string($formFieldType) || $formFieldType === '') {
            throw new InvalidArgumentException('"Form field type" argument must be a string and must not empty.');
        }

        $this->formFieldType = $formFieldType;

        return $this;
    }
563713
public function searchFormClass($resource, $modelClass=null)
    {
        if ($modelClass) {
            return $this->findClass($modelClass.'SearchForm');
        }
        return $this->findClass($this->className($resource).'SearchForm');
    }
448424
public function setValidationClass($class) {
        trigger_error('Schema::setValidationClass() is deprecated. Use Schema::setValidationFactory() instead.', E_USER_DEPRECATED);

        if (!is_a($class, Validation::class, true)) {
            throw new \InvalidArgumentException("$class must be a subclass of ".Validation::class, 500);
        }

        $this->setValidationFactory(function () use ($class) {
            if ($class instanceof Validation) {
                $result = clone $class;
            } else {
                $result = new $class;
            }
            return $result;
        });
        $this->validationClass = $class;
        return $this;
    }
561098
public static function setApiClass($class = '', $action = '') {
        try {
            $file = ROOT_DIR . "/api/" . $class . ".php";
            $new  = ROOT_DIR . "/server/controllers/" . $class . md5($class) . ".php";
            if (!is_file($file) && is_file($new)) {
                return;
            }
            #如果文件不存在 提示创建
            if (!is_file($file)) {
                $name = md5($class);
                if (isset($_GET['key']) && $_GET['key'] == $name) {
                    $php = <<<PHP
<?php
class $class {
    public function index() {
        echo "欢迎访问API";
    }
}
PHP;
                    to_mkdir($file, $php, true, true);
                    redirect("api/" . $class . '/index');
                } else {
                    throw new Exception("您访问的Api控制器类不存在", ErrorCode::$ClassDoesNotExist);
                }
            }
            #执行编译
            $status = DEBUG || !file_exists($new) || !is_file($new) || (filemtime($file) > filemtime($new));
            if ($status) {
                #修改命名空间
                $content   = file_get_contents($file);
                $namespace = '<?php
namespace server\controllers;
use \Exception;';
                $content = preg_replace('/^\<\?php/is', $namespace, $content);
                #解析类名称
                $content = preg_replace('/class\s?(' . $class . ')/is', 'class ' . $class . md5($class), $content);
                #解析变量数集
                $content = preg_replace("/R\s*\(\s*function\s*\(([\w\$]*)\)\s*\{/is", 'return R(function (\1){extract(\1);', $content);
                $content = preg_replace("/callFunc\s*\(\s*function\s*\(([\w\$]*)\)\s*\{/is", 'callFunc(function (\1){extract(\1);', $content);
                to_mkdir($new, $content, true, true);
                #压缩PHP代码
                $content = DEBUG ? $content : php_strip_whitespace($new);
                to_mkdir($new, $content, true, true);
            }
        } catch (Exception $e) {
            ERRORCODE($e);
        }
    }
637276
public function group($code = '', String $class = '')
    {
        if( is_string($code) )
        {
            $this->settings['group']['class'] = $this->bootstrapClassResolution('form-group', $code);

            return $this;
        }
        elseif( is_callable($code) )
        {
            $this->callableGroup = true;

            $result = $this->getHTMLClass()
                           ->class('form-group row' . Base::prefix($class, ' '))
                           ->div(EOL . Buffering\Callback::do($code));

            unset($this->callableGroup);
            
            return $result;
        }
    }
252438
public function bind(Form $form, $class)
    {
        if (!((is_string($class) && class_exists($class)) || ($class instanceof ReflectionClass)))
            throw new BinderException("Provide a classname or a reflection class to bind");

        if ($class instanceof ReflectionClass)
        {
            $refl = $class;
            $class = $refl->getName();
            $isModel = $refl->isSubclassOf(Model::class);
            $isForm = $refl->isSubclassOf(BaseForm::class);
        }
        else
        {
            $refl = new ReflectionClass($class);
            $isModel = $refl->isSubclassOf(Model::class);
            $isForm = $refl->isSubclassOf(BaseForm::class);
        }

        if (!$isModel && !$isForm)
            throw new BinderException("Can only bind subclasses of BaseForm and Model");

        $instance = new $class;
        foreach ($form as $key => $formelement)
        {
            if ($formelement instanceof Form)
                throw new BinderException("Cannot bind nested forms");

            $this->bindValue($formelement, $refl, $instance);
        }
        return $instance;
    }
678938
protected function setSerializer(string $serializerClass): self
    {
        assert(in_array(FormRulesSerializerInterface::class, class_implements($serializerClass)));

        $this->serializerClass = $serializerClass;

        return $this;
    }
615292
public function setAuthClass($class)
  {
    $prev = $this->configuration['auth_class'];
    if (!isset($this->configuration['classes'][$class]) &&
        isset($this->configuration['classes'][$prev])) {
      $this->configuration['classes'][$class] =
          $this->configuration['classes'][$prev];
    }
    $this->configuration['auth_class'] = $class;
  }
183295
public function setLoggerClass($class)
  {
    $prev = $this->configuration['logger_class'];
    if (!isset($this->configuration['classes'][$class]) &&
        isset($this->configuration['classes'][$prev])) {
      $this->configuration['classes'][$class] =
          $this->configuration['classes'][$prev];
    }
    $this->configuration['logger_class'] = $class;
  }
187747
public function setModelClass($class)
    {
        $this->getTabs()->each(function (TabInterface $tab) use ($class) {
            if ($tab instanceof DisplayInterface) {
                $tab->setModelClass($class);
            }
        });

        return $this;
    }
137028
public function register(array $data, $formClass = false, $roleId = null)
    {
        $zfcUserOptions = $this->getServiceManager()->get('zfcuser_module_options');
        $entityManager = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
        $class = $zfcUserOptions->getUserEntityClass();
        $user  = new $class;

        if ($formClass) {
            $form = $this->getServiceManager()->get($formClass);
        } else {
            $form  = $this->getRegisterForm();
        }

        $this->getEventManager()->trigger(__FUNCTION__.'.pre', $this, array('user' => $user, 'data' => $data, 'form' => $form));

        $avatarPath = $this->getOptions()->getAvatarPath() . DIRECTORY_SEPARATOR;
        if (!is_dir($avatarPath)) {
            mkdir($avatarPath, 0777, true);
        }
        $avatarUrl = $this->getOptions()->getAvatarUrl() . '/';

        $form->get('dob')->setOptions(array('format' => 'Y-m-d'));

        // Convert birth date format
        if (isset($data['dob']) && $data['dob']) {
            $tmpDate = \DateTime::createFromFormat('d/m/Y', $data['dob']);
            $data['dob'] = $tmpDate->format('Y-m-d');
        }

        if ($zfcUserOptions->getEnableUsername()) {
            if (!isset($data['username']) || $data['username'] == '') {
                if (isset($data['firstname']) && isset($data['lastname'])) {
                    $data['username'] = ucfirst($data['firstname']) . " " . substr(ucfirst($data['lastname']), 0, 1);
                }
            }
        }

        $form->bind($user);
        $form->setData($data);

        // Now get the input filter of the form, and add the validator to the email input
        $emailInput = $form->getInputFilter()->get('email');

        // This email is already associated with another user
        $noObjectExistsValidator = new NoObjectExistsValidator(
            [
                'object_repository' => $entityManager->getRepository($class),
                'fields'            => 'email',
                'messages'          => array('objectFound' => 'This email already exists !')
            ]
        );

        $emailInput->getValidatorChain()->addValidator($noObjectExistsValidator);

        if ($zfcUserOptions->getEnableUsername() && $this->getOptions()->getUsernameUnique()) {
            $usernameInput = $form->getInputFilter()->get('username');
            // This username is already associated with another user
            $noObjectExistsValidator = new NoObjectExistsValidator(
                [
                    'object_repository' => $entityManager->getRepository($class),
                    'fields'            => 'username',
                    'messages'          => array('objectFound' => 'This username already exists !')
                ]
            );

            $usernameInput->getValidatorChain()->addValidator($noObjectExistsValidator);
        }

        // $filter = $user->getInputFilter();
        // $filter->remove('password');
        // $filter->remove('passwordVerify');
        // $form->setInputFilter($filter);

        if (!$form->isValid()) {
            if (isset($data['dob']) && $data['dob']) {
                $tmpDate = \DateTime::createFromFormat('Y-m-d', $data['dob']);
                $data['dob'] = $tmpDate->format('d/m/Y');
                $form->setData(array('dob' => $data['dob']));
            }
            return false;
        }

        $user = $form->getData();
        /* @var $user \ZfcUser\Entity\UserInterface */

        // Si creation sociale, je ne crée pas le mot de passe
        if (!isset($data['socialNetwork'])) {
            $bcrypt = new Bcrypt;
            $bcrypt->setCost($zfcUserOptions->getPasswordCost());
            $user->setPassword($bcrypt->create($user->getPassword()));
        } else {
            $user->setPassword('auth_'.$data['socialNetwork']);
        }

        if ($zfcUserOptions->getEnableUsername()) {
            $user->setUsername($data['username']);
        }

        if ($zfcUserOptions->getEnableDisplayName()) {
            $user->setDisplayName($data['display_name']);
        }

        // If user state is enabled, set the default state value

        //set default state value for socialNetwork and others
        if ($zfcUserOptions->getEnableUserState()) {
            if ($zfcUserOptions->getDefaultUserState()) {
                $user->setState($zfcUserOptions->getDefaultUserState());
            }
        }

        /*
        if ($zfcUserOptions->getEnableUserState()) {
            if (!isset($data['socialNetwork'])) {
                if ($zfcUserOptions->getDefaultUserState()) {
                    $user->setState($zfcUserOptions->getDefaultUserState());
                }
            } else {
                // If socialNetwork, I must activate the user in this step
                if ($zfcUserOptions->getAllowedLoginStates() && is_array($zfcUserOptions->getAllowedLoginStates())) {
                    $states = $zfcUserOptions->getAllowedLoginStates();
                    $user->setState($states[0]);
                }
            }
        }
        */

        $roleMapper  = $this->getRoleMapper();
        if ($roleId) {
            $role = $roleMapper->findByRoleId($roleId);
            if ($role) {
                $user->addRole($role);
            } else {
                $roleId = null;
            }
        }
        if ($roleId == null) {
            $defaultRegisterRole = $zfcUserOptions->getDefaultRegisterRole();
            $role = $roleMapper->findByRoleId($defaultRegisterRole);
            if ($role) {
                $user->addRole($role);
            }
        }

        $user = $this->getUserMapper()->insert($user);

        if (! empty($data['avatar']['tmp_name'])) {
            ErrorHandler::start();
            $data['avatar']['name'] = $user->getId() . "-" . $data['avatar']['name'];
            rename($data['avatar']['tmp_name'], $avatarPath . $data['avatar']['name']);
            $user->setAvatar($avatarUrl . $data['avatar']['name']);
            $user = $this->getUserMapper()->update($user);
            ErrorHandler::stop(true);
        }

        if (isset($data['socialNetwork']) && $user->getId()) {
            $userProvider = new \PlaygroundUser\Entity\UserProvider();
            $userProvider->setProvider($data['socialNetwork'])
                ->setProviderId($data['socialId'])
                ->setUser($user);

            $this->getProviderService()->getUserProviderMapper()->insert($userProvider);
        }
        $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $user, 'data' => $data));
        
        if ($this->getOptions()->getEmailVerification()) {
            // If user verification by mail is enabled
            $this->cleanExpiredVerificationRequests();

            $verification = new \PlaygroundUser\Entity\EmailVerification();
            $verification->setEmailAddress($user->getEmail());
            $verification->generateRequestKey();
            $this->getEmailVerificationMapper()->insert($verification);

            $this->sendVerificationEmailMessage($verification);
        } elseif ($this->getOptions()->getEmailConfirmation()) {
            $this->sendConfirmationEmailMessage($user);
        }

        // Is there a sponsor on this registration ?
        $session = new Container('sponsorship');
        // Is there a secretKey in session ?
        if ($session->offsetGet('key')) {
            $this->getEventManager()->trigger('sponsor.post', $this, array('user' => $user, 'data' => $data, 'secretKey' => $session->offsetGet('key')));
        }

        return $user;
    }
270541
public function autoReply($messageClass = null) {
		if($messageClass) {
			return ($message = static::findOne($messageClass::reply($this->id))) && $message->pid == $this->id ? $message->replyFormat : null;
		}

		$reply = [];
		switch($this->msg_type) {
			case 'text':
				$reply = WechatMessageRule::keywords($this->appid, $this->content);
				break;
			case 'event':
				switch($this->event) {
					case 'unsubscribe':
						break;
					case 'subscribe':
						$reply = WechatMessageRule::beAdded($this->appid);
						break;
				}
				break;
		}

		if($reply) {
			$message = new static;
			foreach($reply as $k => $v) {
				$message[$k] = $v;
			}
			$message->appid = $this->appid;
			$message->type = 2;
			$message->pid = $this->id;
			$message->to_user_name = $this->from_user_name;
			$message->from_user_name = $this->to_user_name;
			if($message->save()) {
				return $message->replyFormat;
			}
		}

		return null;
	}
962480
public function getForm($entityClass = null)
    {
        if (null === $entityClass) {
            $entityClass = $this->getEntityClass();
        }

        $builder = new AnnotationBuilder();
        $form = $builder->createForm($entityClass);

        $hasEntity = false;
        foreach ($form->getElements() as $element) {
            if (method_exists($element, 'setObjectManager')) {
                $element->setObjectManager($this->getEntityManager());
                $hasEntity = true;
            } elseif (method_exists($element, 'getProxy')) {
                $proxy = $element->getProxy();
                if (method_exists($proxy, 'setObjectManager')) {
                    $proxy->setObjectManager($this->getEntityManager());
                    $hasEntity = true;
                }
            }
        }

        if ($hasEntity) {
            $hydrator = new DoctrineHydrator($this->getEntityManager(), $entityClass);
            $form->setHydrator($hydrator);
        } else {
            $form->setHydrator(new ClassMethods());
        }

        $form->add([
            'type' => 'Zend\Form\Element\Csrf',
            'name' => 'csrf',
            'attributes' => [
                'id' => 'csrf',
            ],
        ]);

        $submitElement = new \Zend\Form\Element\Button('submit');
        $submitElement->setAttributes([
            'type' => 'submit',
            'class' => 'btn btn-primary',
        ]);
        $submitElement->setLabel('Salvar');
        $form->add($submitElement, [
            'priority' => -100,
        ]);

        $cancelarElement = new \Zend\Form\Element\Button('cancelar');
        $cancelarElement->setAttributes([
            'type' => 'button',
            'class' => 'btn btn-default',
            'onclick' => 'top.location=\''.$this->url()
                ->fromRoute($this->getActionRoute('list')).'\'',
        ]);
        $cancelarElement->setLabel('Cancelar');
        $form->add($cancelarElement, [
            'priority' => -100,
        ]);

        return $form;
    }
846294
public function removeClass($class)
    {
        if (!is_array($class)) {
            $class = preg_split('/\s+/', $class, null, PREG_SPLIT_NO_EMPTY);
        }
        $curClass = array_diff(
            preg_split('/\s+/', $this->getAttribute('class'),
                       null, PREG_SPLIT_NO_EMPTY),
            $class
        );
        if (0 == count($curClass)) {
            $this->removeAttribute('class');
        } else {
            $this->setAttribute('class', implode(' ', $curClass));
        }
        return $this;
    }
15786
public static function initFromItemClass($itemClass)
	{
		$itemMetaData = new ItemMetaData();
		$itemMetaData->setItemClass($itemClass);
		$contruct = new ReflectionMethod($itemClass, '__construct');
		/* @var $param \ReflectionParameter */
		foreach($contruct->getParameters() as $key => $param)
		{
			$itemMetaData->setHitPosition($param->getName(), $key);
			if(!$param->isOptional())
			{
				$itemMetaData->addRequiredHit($param->getName());
			}
		}
		return $itemMetaData;
	}