Sets extensions

@param string ...$args

@return Upload
515936
public function extensions(...$args) : Upload
    {
        if( ! empty($args ) )
        {
            $this->settings['extensions'] = implode('|', $args);
        }

        return $this;
    }
1280527
protected function normalizeArgs(array $args)
    {
        $args += [
            'statsFromPackage' => '',
        ];
        $error = $this->app->make('helper/validation/error');
        $normalized = [];

        try {
            /* @var \CommunityTranslation\Service\RateLimit $rateLimitHelper */
            list($normalized['rateLimit_maxRequests'], $normalized['rateLimit_timeWindow']) = $this->app->make(RateLimit::class)->fromWidgetHtml('rateLimit', $this->rateLimit_timeWindow ?: 3600);
        } catch (UserMessageException $x) {
            $error->add($x->getMessage());
        }

        $normalized['maxFileSize'] = null;
        if (isset($args['maxFileSizeValue']) && (is_int($args['maxFileSizeValue']) || (is_string($args['maxFileSizeValue']) && is_numeric($args['maxFileSizeValue'])))) {
            $maxFileSizeValue = (int) $args['maxFileSizeValue'];
            if ($maxFileSizeValue > 0) {
                $maxFileSizeUnit = $this->post('maxFileSizeUnit');
                $p = is_string($maxFileSizeUnit) ? array_search($maxFileSizeUnit, ['b', 'KB', 'MB', 'GB'], true) : false;
                if ($p === false) {
                    $error->add(t('Please specify the unit of the max size of uploaded files'));
                } else {
                    $maxFileSize = (int) $maxFileSizeValue * pow(1024, $p);
                    $postLimit = $this->getPostLimit();
                    if ($postLimit !== null && $maxFileSize > $postLimit) {
                        $nh = $this->app->make('helper/number');
                        $error->add(
                            t(
                                'You can\'t set the max file size to %1$s since the current limit imposed by PHP is %2$s',
                                $nh->formatSize($maxFileSize),
                                $nh->formatSize($postLimit)
                            )
                        );
                    } else {
                        $normalized['maxFileSize'] = $maxFileSize;
                    }
                }
            }
        }
        $normalized['maxLocalesCount'] = null;
        if (isset($args['maxLocalesCount']) && (is_int($args['maxLocalesCount']) || (is_string($args['maxLocalesCount']) && is_numeric($args['maxLocalesCount'])))) {
            $i = (int) $args['maxLocalesCount'];
            if ($i > 0) {
                $normalized['maxLocalesCount'] = $i;
            }
        }
        $normalized['maxStringsCount'] = null;
        if (isset($args['maxStringsCount']) && (is_int($args['maxStringsCount']) || (is_string($args['maxStringsCount']) && is_numeric($args['maxStringsCount'])))) {
            $i = (int) $args['maxStringsCount'];
            if ($i > 0) {
                $normalized['maxStringsCount'] = $i;
            }
        }
        $normalized['statsFromPackage'] = '';
        if (is_string($args['statsFromPackage'])) {
            $normalized['statsFromPackage'] = trim($args['statsFromPackage']);
            if ($normalized['statsFromPackage'] !== '') {
                $package = $this->app->make(PackageRepository::class)->findOneBy(['handle' => $normalized['statsFromPackage']]);
                if ($package === null) {
                    $error->add(t('Unable to find a package with handle "%s"', $normalized['statsFromPackage']));
                } elseif ($package->getLatestVersion() === null) {
                    $error->add(t('The package with handle "%s" does not have a latest version', $normalized['statsFromPackage']));
                }
            }
        }

        return $error->has() ? $error : $normalized;
    }
285134
public function after_upload($cb, $args = '')
    {
        if (is_callable($cb)) {
            $this->upload_callback      = $cb;
            $this->upload_callback_args = $args;
        } else {
            /* some sort of error... */
        }

        return $this;
    }
1150025
public function setArguments(array $arguments)
    {
        foreach ($arguments as $arg) {
            if (!is_scalar($arg)) {
                $type = gettype($arg);
                throw new DomainException("Arguments array should be an array of scalar, but found $type");
            }
        }

        $this->arguments = $arguments;

        return $this;
    }
788620
protected function set_request_args( $args ) {

		$this->request_method = $args['method'];
		$this->request_path   = isset( $args['path'] ) ? $args['path'] : null;
		$this->request_params = isset( $args['params'] ) ? $args['params'] : null;
		$this->request_body   = isset( $args['body'] ) ? $args['body'] : null;

		// set the top-level JSON object namespace if not already set, this is mainly
		// a convenience for client code so creating/updating resources doesn't need a
		// nested array like array( 'order_note' => array( 'note' => 'foo' ) ) and can instead
		// use array( 'note' => 'foo' ) ʘ‿ʘ
		if ( $this->request_body && ! isset( $args['body'][ $this->object_namespace ] ) ) {

			$this->request_body = array(
				$this->object_namespace => $this->request_body,
			);
		}

		// convert bool true to string 'true', required for DELETE endpoints
		if ( isset( $this->request_params['force'] ) && $this->request_params['force'] ) {
			$this->request_params['force'] = 'true';
		}
	}
1108498
public function setArguments(array $args): PostTypeInterface
    {
        $this->args = array_merge($this->args, $args);

        return $this;
    }
1215768
static function upload( $args )
    {
        try
        {
            $handler = self::getHandler( $args );
            $fileInfo = $handler->getFileinfo();
            $mimeData = $fileInfo['mime'];
            $file = $fileInfo['file'];
            $class = $handler->getContentClass( $mimeData );

            if ( $file->store( false, $mimeData['suffix'] ) === false )
            {
                throw new RuntimeException(
                    ezpI18n::tr(
                        'extension/ezjscore/ajaxuploader',
                        'Unable to store the uploaded file.'
                    )
                );
            }
            else
            {
                $fileHandler = eZClusterFileHandler::instance();
                $fileHandler->fileStore( $file->attribute( 'filename' ), 'tmp', true, $file->attribute( 'mime_type' ) );
            }

            $start = $handler->getDefaultParentNodeId( $class );
            $defaultParentNode = eZContentObjectTreeNode::fetch( $start );
            if ( !$defaultParentNode instanceof eZContentObjectTreeNode )
            {
                throw new RuntimeException(
                    ezpI18n::tr(
                        "extension/ezjscore/ajaxuploader",
                        "The default parent location for uploads cannot be retrieved! Check user permissions and correctness of settings."
                    )
                );
            }
        }
        catch ( Exception $e )
        {
            // manually catch exception to force json encode
            // because most browsers cannot upload
            // wit a json HTTP Accept header...
            // see JavaScript code in eZAjaxUploader::delegateWindowEvents();
            return json_encode(
                array(
                    'error_text' => $e->getMessage(),
                    'content' => ''
                )
            );
        }

        $browseItems = self::getBrowseItems( $defaultParentNode->attribute( 'parent' ), $class );

        $http = eZHTTPTool::instance();
        $tpl = eZTemplate::factory();
        $tpl->setVariable( 'file', $file );
        $tpl->setVariable( 'name', $http->postVariable( 'UploadName', $file->attribute( 'original_filename' ) ) );
        $tpl->setVariable( 'mime_data', $mimeData );
        $tpl->setVariable( 'class', $class );
        $tpl->setVariable( 'browse_start', $defaultParentNode->attribute( 'parent' ) );
        $tpl->setVariable( 'default_parent_node', $defaultParentNode );
        $tpl->setVariable( 'browse', $browseItems );
        // json_encode and url encode the HTML to be able to get it in the
        // JavaScript code. see eZAjaxUploader::delegateWindowEvents()
        return json_encode(
            array(
                'meta_data' => false,
                'html' => rawurlencode(
                    $tpl->fetch( 'design:ajaxuploader/location.tpl' )
                )
            )
        );
    }
993763
public function additionalArgs(array $args) : void
    {
        foreach ($args as $a) {
            //match --extends
            if (substr($a, 0, strlen("--extends=")) == "--extends=") {
                $this->extends = explode("=", $a);
                $this->extends = $this->extends[1];
                continue;
            }

            if ($a == "--no-factory") {
                $this->createFactory = false;
                continue;
            }

            if (substr($a, 0, strlen("--test=")) == "--test=") {
                $this->test = explode("=", $a)[1];
                continue;
            }
        }
    }
97690
public function addShould($args)
    {
        $this->boolQuery->addShould($args);
        $this->query = new \Elastica\Query($this->boolQuery);
    }
19870
public function orOn(...$args)
    {
        $this->createToken(
            'OR',
            $args,
            $this->joinTokens[$this->activeJoin]['on'],
            $this->onWrapper()
        );

        return $this;
    }
34956
public function add(array $args)
    {
        # Establish args.

        $default_args = [
            'auto_prefix'        => true,
            'include_post_types' => [],
            'exclude_post_types' => [],
            'slug'               => '',
            'title'              => '',
            'class'              => '',
            'template_file'      => '',
            'template_dir'       => '',
            'callback'           => null,
            'on_save'            => null,
            'screen'             => null,
            'context'            => 'advanced',
            'priority'           => 'default',
        ];
        $cfg = (object) array_merge($default_args, $args);

        $cfg->auto_prefix        = (bool) $cfg->auto_prefix;
        $cfg->include_post_types = (array) $cfg->include_post_types;
        $cfg->exclude_post_types = (array) $cfg->exclude_post_types;
        $cfg->slug               = (string) $cfg->slug;
        $cfg->title              = (string) $cfg->title;
        $cfg->class              = (string) $cfg->class;
        $cfg->template_file      = (string) $cfg->template_file;
        $cfg->template_dir       = (string) $cfg->template_dir;
        $cfg->context            = (string) $cfg->context;
        $cfg->priority           = (string) $cfg->priority;

        if ($cfg->slug && $cfg->auto_prefix) {
            $cfg->slug = $this->App->Config->©brand['©slug'].'-'.$cfg->slug;
        } elseif (!$cfg->slug) {
            $cfg->slug = $this->App->Config->©brand['©slug'];
        }
        if (!$cfg->title) {
            $cfg->title = $this->App->Config->©brand['©name'];
        }
        $cfg->class .= $cfg->class ? ' ' : '';
        $cfg->class .= $this->App::CORE_CONTAINER_SLUG.'-menu-page-area';
        $cfg->class .= ' '.$this->App::CORE_CONTAINER_SLUG.'-post-meta-box-wrapper';
        $cfg->class .= ' '.$this->App->Config->©brand['©slug'].'-post-meta-box-wrapper';
        $cfg->class .= $cfg->slug !== $this->App->Config->©brand['©slug'] ? ' '.$cfg->slug.'-post-meta-box-wrapper' : '';

        $cfg->nonce['action'] = $cfg->slug.'-save'; // Nonce action ID.
        $cfg->nonce['name']   = '_'.$this->c::slugToVar($cfg->slug).'_nonce';

        $cfg = $this->s::applyFilters('post_meta_box', $cfg, $args, $default_args);

        if (!$cfg->template_file) {
            throw $this->c::issue('Missing template file.');
        }
        $cfg->callback = $cfg->callback ?: function (\WP_Post $WP_Post) use ($cfg) {
            $post_id = (int) $WP_Post->ID;
            $vars    = compact('post_id', 'WP_Post', 'cfg');
            wp_nonce_field($cfg->nonce['action'], $cfg->nonce['name']);
            echo $this->c::getTemplate('s-core/admin/menu-pages/post-meta-box/template.php')->parse($vars);
        };
        # Build meta box sub-routines via closures.

        $on_load_maybe_do_setup = function () use ($cfg) {
            $current_post_type = $this->s::currentMenuPagePostType();

            if ($cfg->include_post_types && !in_array($current_post_type, $cfg->include_post_types, true)) {
                return; // Does not apply to this post type.
            } elseif ($cfg->exclude_post_types && in_array($current_post_type, $cfg->exclude_post_types, true)) {
                return; // Does not apply to this post type.
            }
            $on_add_meta_boxes = function () use ($cfg) {
                add_meta_box($cfg->slug, $cfg->title, $cfg->callback, $cfg->screen, $cfg->context, $cfg->priority);
            };
            $on_save_post = function ($post_id, \WP_Post $WP_Post) use ($cfg) {
                if (!($post_id = (int) $post_id)) {
                    return; // Not possible.
                }
                $_r = $this->c::unslash($_REQUEST);
                $_r = $this->c::mbTrim($_r);

                $nonce_action = $cfg->nonce['action'];
                $nonce_value  = $_r[$cfg->nonce['name']] ?? null;

                $data = $_r[$this->c::slugToVar($cfg->slug)] ?? [];
                $data = is_array($data) ? $data : []; // Force array.
                $data = $this->c::removeKey($data, '___ignore');

                if (!isset($nonce_value)) {
                    return; // Nonce is missing.
                } elseif (!wp_verify_nonce($nonce_value, $nonce_action)) {
                    return; // Nonce is unverifiable.
                } elseif (!current_user_can('edit_post', $post_id)) {
                    return; // Current user not allowed.
                } elseif (wp_is_post_autosave($post_id)) {
                    return; // Not applicable.
                } elseif (wp_is_post_revision($post_id)) {
                    return; // Not applicable.
                }
                foreach ($data as $_key => $_value) {
                    if ($_key && is_string($_key)) {
                        // Slash, because WP will unslash.
                        // This allows for `\` in form submissions.
                        $this->s::updatePostMeta($post_id, $_key, wp_slash($_value));
                    }
                }
                if (($on_save = $cfg->on_save)) {
                    $on_save($post_id, $data);
                }
            };
            add_action('add_meta_boxes', $on_add_meta_boxes);
            add_action('save_post', $on_save_post, 10, 2);
        };
        add_action('load-post.php', $on_load_maybe_do_setup);
        add_action('load-post-new.php', $on_load_maybe_do_setup);
    }
392964
public function setPost($data, ...$args)
    {
        if (is_array($data)) {
            return $this->set('post', $data);
        }

        if (count($args) === 0) {
            return $this;
        }

        return $this->set('post', $data, ...$args);
    }
600725
public function setResponseArray(array $args = [])
    {
        foreach ($args as $name => $text) {
            return $this->response[$name] = $text;
        }
        return $this;
    }
1256519
public function setExtensions(array $extensions)
    {
        $this->extensions = [];
        foreach ($extensions as $extension) {
            $this->addExtension($extension);
        }

        return $this;
    }
1006585
protected function put($args) {
		$target = $args['target'];
		
		if (($volume = $this->volume($target)) == false
		|| ($file = $volume->file($target)) == false) {
			return array('error' => $this->error(self::ERROR_SAVE, '#'.$target, self::ERROR_FILE_NOT_FOUND));
		}
		
		if (($file = $volume->putContents($target, $args['content'])) == false) {
			return array('error' => $this->error(self::ERROR_SAVE, $volume->path($target), $volume->error()));
		}
		
		return array('changed' => array($file));
	}
53767
public function setExtensions($extensions)
    {
        $this->_extensions = array();
        $token             = ' ,;';
        $extension         = strtok($extensions, $token);

        while ($extension !== false) {
            $this->_extensions[] = $extension;
            $extension           = strtok($token);
        }

    }
508769
public function setArguments($arguments)
    {
        foreach ($arguments as $name => $argument) {
            $this->setArgument($name, $argument);
        }

        return $this;
    }