mirror of
https://github.com/flextype/flextype.git
synced 2025-01-16 20:28:17 +01:00
refactor(core): code updates and improvements - doctrine
This commit is contained in:
parent
5a344b6c52
commit
eeb0875a1a
14
bin/flextype
14
bin/flextype
@ -15,20 +15,10 @@
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
/**
|
||||
* Define the Flextype start time in current unix timestamp (microseconds).
|
||||
*/
|
||||
define('FLEXTYPE_START_TIME', microtime(true));
|
||||
|
||||
/**
|
||||
* Define the PATH to the root directory (without trailing slash).
|
||||
*/
|
||||
define('FLEXTYPE_ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
|
||||
|
||||
/**
|
||||
* Ensure vendor libraries exist
|
||||
*/
|
||||
! is_file($flextypeAutoload = FLEXTYPE_ROOT_DIR . '/vendor/autoload.php') and exit('Please run: <i>composer install</i> for flextype');
|
||||
! is_file($flextypeAutoload = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()) . '/vendor/autoload.php') and exit('Please run: <i>composer install</i> for flextype');
|
||||
|
||||
/**
|
||||
* Register The Auto Loader
|
||||
@ -49,4 +39,4 @@ $flextypeLoader = require_once $flextypeAutoload;
|
||||
* the responses back to the browser and delight our users.
|
||||
*/
|
||||
|
||||
require_once FLEXTYPE_ROOT_DIR . '/src/flextype/flextype.php';
|
||||
require_once rtrim(__DIR__, '/bin') . '/src/flextype/flextype.php';
|
13
index.php
13
index.php
@ -18,23 +18,12 @@ namespace Flextype;
|
||||
|
||||
use function getcwd;
|
||||
use function is_file;
|
||||
use function sprintf;
|
||||
use function str_replace;
|
||||
|
||||
/**
|
||||
* Define the Flextype start time in current unix timestamp (microseconds).
|
||||
*/
|
||||
define('FLEXTYPE_START_TIME', microtime(true));
|
||||
|
||||
/**
|
||||
* Define the PATH to the root directory (without trailing slash).
|
||||
*/
|
||||
define('FLEXTYPE_ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
|
||||
|
||||
/**
|
||||
* Ensure vendor libraries exist
|
||||
*/
|
||||
! is_file($flextypeAutoload = __DIR__ . '/vendor/autoload.php') and exit('Please run: <i>composer install</i> for flextype');
|
||||
! is_file($flextypeAutoload = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()) . '/vendor/autoload.php') and exit('Please run: <i>composer install</i> for flextype');
|
||||
|
||||
/**
|
||||
* Register The Auto Loader
|
||||
|
@ -1,6 +1,8 @@
|
||||
parameters:
|
||||
level: 0
|
||||
level: 1
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
bootstrapFiles:
|
||||
- src/flextype/defines.php
|
||||
paths:
|
||||
- src
|
||||
ignoreErrors:
|
||||
|
@ -96,7 +96,7 @@ class Driver implements AggregatablePoolInterface
|
||||
$data = $this->driverPreWrap($item);
|
||||
|
||||
try {
|
||||
return $this->writeFile($filePath, serializers()->phparray()->encode($data), $this->getConfig()->isSecureFileManipulation(), $this->getConfig()->isSecureFileManipulation());
|
||||
return $this->writeFile($filePath, serializers()->phparray()->encode($data), $this->getConfig()->isSecureFileManipulation());
|
||||
} catch (Throwable) {
|
||||
return false;
|
||||
}
|
||||
|
@ -111,6 +111,8 @@ class EntriesFetchCommand extends Command
|
||||
if ($input->getOption('filter-where')) {
|
||||
$filterWhere = $input->getOption('filter-where');
|
||||
|
||||
$where = [];
|
||||
|
||||
foreach ($filterWhere as $key => $value) {
|
||||
if (strings($value)->isJson()) {
|
||||
$whereValues = serializers()->json()->decode($value);
|
||||
|
@ -111,6 +111,8 @@ class TokensFetchCommand extends Command
|
||||
if ($input->getOption('filter-where')) {
|
||||
$filterWhere = $input->getOption('filter-where');
|
||||
|
||||
$where = [];
|
||||
|
||||
foreach ($filterWhere as $key => $value) {
|
||||
if (strings($value)->isJson()) {
|
||||
$whereValues = serializers()->json()->decode($value);
|
||||
|
@ -100,8 +100,6 @@ final class Shortcodes
|
||||
public function initShortcodes(array $shortcodes): void
|
||||
{
|
||||
if (
|
||||
! isset($shortcodes) ||
|
||||
! is_array($shortcodes) ||
|
||||
count($shortcodes) <= 0
|
||||
) {
|
||||
return;
|
||||
|
@ -19,11 +19,25 @@ namespace Flextype;
|
||||
use function define;
|
||||
use function defined;
|
||||
|
||||
if (! defined('FLEXTYPE_START_TIME')) {
|
||||
/**
|
||||
* Define the Flextype start time in current unix timestamp (microseconds).
|
||||
*/
|
||||
define('FLEXTYPE_START_TIME', microtime(true));
|
||||
}
|
||||
|
||||
if (! defined('FLEXTYPE_ROOT_DIR')) {
|
||||
/**
|
||||
* Define the PATH to the root directory (without trailing slash).
|
||||
*/
|
||||
define('FLEXTYPE_ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
|
||||
}
|
||||
|
||||
if (! defined('FLEXTYPE_MINIMUM_PHP')) {
|
||||
/**
|
||||
* Define the Flextype Application minimum supported PHP version.
|
||||
*/
|
||||
define('FLEXTYPE_MINIMUM_PHP', '7.4.0');
|
||||
define('FLEXTYPE_MINIMUM_PHP', '8.1.0');
|
||||
}
|
||||
|
||||
if (! defined('FLEXTYPE_PROJECT_NAME')) {
|
||||
|
@ -69,7 +69,7 @@ use function version_compare;
|
||||
use const PHP_VERSION;
|
||||
|
||||
// Get defines.
|
||||
require_once FLEXTYPE_ROOT_DIR . '/src/flextype/defines.php';
|
||||
require_once str_replace(DIRECTORY_SEPARATOR, '/', getcwd()) . '/src/flextype/defines.php';
|
||||
|
||||
// Check PHP Version
|
||||
version_compare($ver = PHP_VERSION, $req = FLEXTYPE_MINIMUM_PHP, '<') and exit(sprintf('You are running PHP %s, but Flextype needs at least <strong>PHP %s</strong> to run.', $ver, $req));
|
||||
|
@ -19,7 +19,20 @@ if (! function_exists('imageFile')) {
|
||||
* @param string $file Image file.
|
||||
* @param array $options Options array.
|
||||
*/
|
||||
function imageFile(string $file, array $options = []): Image|null
|
||||
function imageFile(string $file): Image
|
||||
{
|
||||
return Image::make($file);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('imageProcessFile')) {
|
||||
/**
|
||||
* Process image file.
|
||||
*
|
||||
* @param string $file Image file.
|
||||
* @param array $options Options array.
|
||||
*/
|
||||
function imageProcessFile(string $file, array $options = [])
|
||||
{
|
||||
$image = Image::make($file);
|
||||
|
||||
|
@ -59,7 +59,7 @@ if (! function_exists('upload')) {
|
||||
$mediaFile = $uploadFolder . '/' . $result->name;
|
||||
|
||||
if (getimagesize($mediaFile)) {
|
||||
imageFile($mediaFile, $settings['process']['image']);
|
||||
imageProcessFile($mediaFile, $settings['process']['image']);
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user