Determine if we can create a Model with name

{@inheritDoc}
@see \Zend\ServiceManager\Factory\AbstractFactoryInterface::canCreate()
195945
public function canCreate(ContainerInterface $container, $requestedName)
    {
        $namespace = $this->getConfig($container)['namespace'];
        $ar = explode('_', $requestedName);

        return (count($ar) >= 2 && array_key_exists($ar[0], $namespace) && $ar[1] === 'model');
    }
226647
protected function _actionCreate(ModelContext $context)
    {
        //Get the data
        $data = ModelContext::unbox($context->properties);

        //Create the entity identifier
        $identifier = $this->getIdentifier()->toArray();
        $identifier['path'] = array('model', 'entity');

        if($data && !is_numeric(key($data))) {
            $identifier['name'] = StringInflector::singularize($identifier['name']);
        } else {
            $identifier['name'] = StringInflector::pluralize($identifier['name']);
        }

        $options = array(
            'data'         => $data,
            'identity_key' => $context->getIdentityKey()
        );

        return $this->getObject($identifier, $options);
    }
401082
public function canCreate($member = null, $context = array())
    {
        if (!$member) {
            $member = Security::getCurrentUser();
        }

        $result = $this->extendedCan('canCreate', $member, $context);
        if ($result !== null) {
            return $result;
        }

        if (Permission::checkMember($member, self::EDIT_ALL)) {
            return true;
        }

        // If Parent is provided, file can be created if parent can be edited
        /** @var Folder $parent */
        $parent = isset($context['Parent']) ? $context['Parent'] : null;
        if ($parent) {
            return $parent->canEdit($member);
        }

        return false;
    }
520036
private function canUpdate()
    {
        $this->info("Validating");

        // Exists as a directory
        if(!file_exists(pluginsPath($this->pluginNamespace))) {
            throw new \Exception("Plugin ".$this->pluginNamespace." not found in plugins directory!");
        }

        // Plugin should be in DB Table
        if(!Plugin::where('namespace', $this->pluginNamespace)->first()) {
            throw new \Exception("Plugin ".$this->pluginNamespace." doesn't exists in DB!");
        }

        // Clear laravel compiled files
        $this->callSilent('clear-compiled');

        // Remove composer autoloader
        //        exec('composer dump-autoload', $output, $return_var);

        // Plugin class exists
        $fullNamespace =  'Plugins\\'.str_replace('/', '\\', $this->pluginNamespace.'\\Plugin');

        if(!class_exists($fullNamespace)) {
            // When composer autoload was generated, we didn't have this plugin's classes
            // that's why we have to autoload all Plugin' classes manually
            spl_autoload_register(
                function ($class) {
                    $class = str_replace("\\", "/", $class);
                    $class = str_replace("Plugins", "plugins", $class);
                    include base_path().'/' . $class. '.php';
                }
            );
        }

        // Make sure Plugin namespace class exist
        if(!class_exists($fullNamespace)) {
            throw new \Exception("Class $fullNamespace not found!");
        }

        // Plugin needs to have an "update" method
        $this->pluginInstance = new $fullNamespace();
        if(!method_exists($this->pluginInstance, 'update')) {
            throw new \Exception("Plugin ".$this->pluginNamespace." does not have an update method!");
        }

        // Config file exist
        if(!file_exists(pluginsPath($this->pluginNamespace.'/config.json'))) {
            throw new \Exception("Plugin ".$this->pluginNamespace." config.file does not exists!");
        }
        return true;
    }
91017
public function canCreate(\Interop\Container\ContainerInterface $container, $requestedName)
    {
        $this->getConfig($container, $requestedName);
        return isset($this->dependencies[$requestedName]);
    }
480594
public function canCreate($member = null, $context = [])
    {
        // Check parent object
        $parent = $this->Parent();
        if ($parent) {
            return $parent->canCreate($member);
        }

        // Fall back to secure admin permissions
        return parent::canCreate($member);
    }
1194664
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if (!array_key_exists($requestedName, $this->dataForModuleOptionsCreate)) {
            if (!$serviceLocator instanceof ModuleOptionsPluginManagerInterface) {
                return false;
            }
            /** @var ModuleOptionsPluginManagerInterface $serviceLocator  */
            $this->buildDataForModuleOptionsCreate($serviceLocator, $requestedName);
        }

        return false !== $this->dataForModuleOptionsCreate[$requestedName];
    }
670986
public function canCreate($member = null, $context = [])
    {
        if (isset($context['Parent'])) {
             return $context['Parent']->canEdit();
        }
        return $this->MenuSet()->canEdit();
    }
853410
public function canGenerateMethod($methodName)
    {
        /**
         * any special methods only called by the base mock class
         * and therefor should not be made accessible
         *
         * @see \JSiefer\ClassMocker\Mock\BaseMock::__callTraitMethods()
         */
        switch ($methodName) {
            case BaseMock::CALL:
            case BaseMock::CONSTRUCTOR:
            case BaseMock::GETTER:
            case BaseMock::SETTER:
            case BaseMock::INIT:
                return false;
        }
        return true;
    }
1648
public function extend($name, $callable, $strict = true)
    {
        if (!$this->services->has($name)) {
            if ($strict) {
                throw new InvalidArgumentException(sprintf('Service "%s" is not defined.', $name));
            } else {
                return false;
            }
        }

        $factory = $this->services->get($name);

        if (!is_object($factory) || !method_exists($factory, '__invoke')) {
            throw new InvalidArgumentException(sprintf('Service "%s" does not contain an object definition.', $name));
        }

        if (!is_object($callable) || !method_exists($callable, '__invoke')) {
            throw new InvalidArgumentException('Extension service definition is not a Closure or invokable object.');
        }

        $extended = function($c) use($callable, $factory) {
            /** @var Closure $factory */
            return $callable($factory($c), $c);
        };

        if ($this->factories->contains($factory)) {
            $this->factories->detach($factory);
            $this->factories->attach($extended);
        }

        $this->services->unlock($name);
        $this->services->set($name, $extended);

        return $this->services->get($name);
    }
1239238
protected function isModelDeletable(Model $model)
    {
        $this->lastUnmetDeleteConditionMessage = null;

        // access rights
        if ( ! $this->isAuthorizedToDelete()) {
            $this->lastUnmetDeleteConditionMessage = $this->getUnmetConditionMessageForAuthorizationFailure();
            return false;
        }

        // delete condition & model configuration
        $info = $this->getModelInformation();

        if ( ! $info->allowDelete()) {
            $this->lastUnmetDeleteConditionMessage = $this->getUnmetConditionMessageForDisallowedFailure();
            return false;
        }

        $condition = $info->deleteCondition();

        if ( ! $condition) {
            return true;
        }

        // Resolve condition and check.
        $strategies = $this->interpretDeleteCondition($condition);

        foreach ($strategies as $strategy => $parameters) {

            /** @var DeleteConditionStrategyFactoryInterface $factory */
            $factory = app(DeleteConditionStrategyFactoryInterface::class);
            $strategy = $factory->make($strategy);

            if ( ! $strategy->check($model, $parameters)) {
                $this->lastUnmetDeleteConditionMessage = $strategy->message();
                return false;
            }
        }

        return true;
    }
1123191
public function canCreate(ContainerInterface $container, $requestedName)
    {
        $config = $container->get("config");
        return (
            isset($config[static::KEY][$requestedName][static::KEY_CLASS]) &&
            is_a($config[static::KEY][$requestedName][static::KEY_CLASS], static::KEY_DEFAULT_CLASS, true)
        );
    }
519999
public function canCreate(ContainerInterface $serviceLocator, $requestedName)
    {
        if (substr($requestedName, -6) == self::WIDGET_SUFFIX) {
            /** @var $util \PageBuilder\Util\Widget */
            $util     = $serviceLocator->get('util\widget');
            $widgetId = str_replace(self::WIDGET_SUFFIX, '', $requestedName);

            return $util->widgetExist($widgetId);
        }

        return false;
    }
541499
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $this->getConfig($serviceLocator);

        if (empty($config)) {
            return false;
        }

        $serviceConfig = $this->checkHasRequestedNameConfig($config, $requestedName);
        $transportConfig = $this->checkHasTransportConfig($config, $requestedName, $serviceLocator);

        return $serviceConfig && $transportConfig;
    }
1177112
public function canCreate($member = null, $context = [])
    {
        $extended = $this->extendedCan(__FUNCTION__, $member);
        if ($extended !== null) {
            return $extended;
        }
        return $this->Parent()->canCreate();
    }
82048
public function makeModel($modelName = null)
  {
    $modelName = ucwords($_POST['command']);

    $this->$modelName = $modelName;

    if (file_exists("App/Models/{$this->$modelName}.php")) {
      $this->errors[] = "The model {$this->$modelName} already exists!";
    } elseif (strripos($this->$modelName, '_') == 0) {
      $this->$modelName = ucwords(str_replace('_', '', $this->$modelName));
    }

    if (!empty($this->errors)) {
      echo array_shift($this->errors);
    } else {
      $newModelTemplate = file_get_contents(__DIR__ . '/templates/makeModel.txt');
      $newModel = str_replace('ModelName', $this->$modelName, $newModelTemplate);
      file_put_contents("App/Models/{$this->$modelName}.php", $newModel);
    }

  }
754720
private function createServiceFromFactory(string $name, array $options = null)
    {
        $factory = $this->factories[$name] ?? null;

        if (is_string($factory) && class_exists($factory)) {
            $factory = new $factory();
            if ($factory instanceof FactoryInterface) {
                $this->factories[$name] = $factory;
                return $factory($this->creationContext, $name, $options);
            }
            throw InvalidArgumentException::fromInvalidFactory($factory);
        }

        if (is_callable($factory)) {
            return $factory($this->creationContext, $name, $options);
        } elseif (isset($this->invokables[$name])) {
            $invokable = $this->invokables[$name];
            return $options === null ? new $invokable() : new $invokable($options);
        }

        foreach ($this->abstractFactories as $idx => $abstractFactory) {
            if ($abstractFactory->canCreate($this->creationContext, $name)) {
                return $abstractFactory($this->creationContext, $name, $options);
            }
        }

        throw ServiceNotFoundException::fromUnknownService($name);
    }