diff --git a/.idea/hesabixCore.iml b/.idea/hesabixCore.iml
index 1e4a1d0..b3edbfd 100644
--- a/.idea/hesabixCore.iml
+++ b/.idea/hesabixCore.iml
@@ -36,6 +36,13 @@
+
+
+
+
+
+
+
diff --git a/.idea/php.xml b/.idea/php.xml
index 83872f4..24bd864 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -63,6 +63,13 @@
+
+
+
+
+
+
+
diff --git a/.idea/symfony2.xml b/.idea/symfony2.xml
index bd98e40..3298060 100644
--- a/.idea/symfony2.xml
+++ b/.idea/symfony2.xml
@@ -2,5 +2,6 @@
+
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 4911bd9..1045457 100644
--- a/composer.json
+++ b/composer.json
@@ -7,16 +7,22 @@
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
+ "doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.8",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.14",
"nelmio/cors-bundle": "^2.2",
+ "phpdocumentor/reflection-docblock": "^5.3",
+ "phpstan/phpdoc-parser": "^1.16",
"symfony/console": "6.2.*",
"symfony/dotenv": "6.2.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "6.2.*",
+ "symfony/property-access": "6.2.*",
+ "symfony/property-info": "6.2.*",
"symfony/runtime": "6.2.*",
"symfony/security-bundle": "6.2.*",
+ "symfony/serializer": "6.2.*",
"symfony/yaml": "6.2.*",
"symfonycasts/verify-email-bundle": "^1.13"
},
diff --git a/composer.lock b/composer.lock
index 6a50d4b..00d0566 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,84 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "b769efde9eff86f833f47b14e5c80c52",
+ "content-hash": "8d4b2d3b5f2fa1e504ae31e3e56e7920",
"packages": [
+ {
+ "name": "doctrine/annotations",
+ "version": "1.14.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/annotations.git",
+ "reference": "fb0d71a7393298a7b232cbf4c8b1f73f3ec3d5af"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/annotations/zipball/fb0d71a7393298a7b232cbf4c8b1f73f3ec3d5af",
+ "reference": "fb0d71a7393298a7b232cbf4c8b1f73f3ec3d5af",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/lexer": "^1 || ^2",
+ "ext-tokenizer": "*",
+ "php": "^7.1 || ^8.0",
+ "psr/cache": "^1 || ^2 || ^3"
+ },
+ "require-dev": {
+ "doctrine/cache": "^1.11 || ^2.0",
+ "doctrine/coding-standard": "^9 || ^10",
+ "phpstan/phpstan": "~1.4.10 || ^1.8.0",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
+ "symfony/cache": "^4.4 || ^5.4 || ^6",
+ "vimeo/psalm": "^4.10"
+ },
+ "suggest": {
+ "php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Guilherme Blanco",
+ "email": "guilhermeblanco@gmail.com"
+ },
+ {
+ "name": "Roman Borschel",
+ "email": "roman@code-factory.org"
+ },
+ {
+ "name": "Benjamin Eberlei",
+ "email": "kontakt@beberlei.de"
+ },
+ {
+ "name": "Jonathan Wage",
+ "email": "jonwage@gmail.com"
+ },
+ {
+ "name": "Johannes Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Docblock Annotations Parser",
+ "homepage": "https://www.doctrine-project.org/projects/annotations.html",
+ "keywords": [
+ "annotations",
+ "docblock",
+ "parser"
+ ],
+ "support": {
+ "issues": "https://github.com/doctrine/annotations/issues",
+ "source": "https://github.com/doctrine/annotations/tree/1.14.3"
+ },
+ "time": "2023-02-01T09:20:38+00:00"
+ },
{
"name": "doctrine/cache",
"version": "2.2.0",
@@ -1519,6 +1595,216 @@
},
"time": "2021-12-01T09:34:27+00:00"
},
+ {
+ "name": "phpdocumentor/reflection-common",
+ "version": "2.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpDocumentor/ReflectionCommon.git",
+ "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
+ "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-2.x": "2.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "phpDocumentor\\Reflection\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jaap van Otterdijk",
+ "email": "opensource@ijaap.nl"
+ }
+ ],
+ "description": "Common reflection classes used by phpdocumentor to reflect the code structure",
+ "homepage": "http://www.phpdoc.org",
+ "keywords": [
+ "FQSEN",
+ "phpDocumentor",
+ "phpdoc",
+ "reflection",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
+ "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
+ },
+ "time": "2020-06-27T09:03:43+00:00"
+ },
+ {
+ "name": "phpdocumentor/reflection-docblock",
+ "version": "5.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
+ "reference": "622548b623e81ca6d78b721c5e029f4ce664f170"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170",
+ "reference": "622548b623e81ca6d78b721c5e029f4ce664f170",
+ "shasum": ""
+ },
+ "require": {
+ "ext-filter": "*",
+ "php": "^7.2 || ^8.0",
+ "phpdocumentor/reflection-common": "^2.2",
+ "phpdocumentor/type-resolver": "^1.3",
+ "webmozart/assert": "^1.9.1"
+ },
+ "require-dev": {
+ "mockery/mockery": "~1.3.2",
+ "psalm/phar": "^4.8"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "5.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "phpDocumentor\\Reflection\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Mike van Riel",
+ "email": "me@mikevanriel.com"
+ },
+ {
+ "name": "Jaap van Otterdijk",
+ "email": "account@ijaap.nl"
+ }
+ ],
+ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
+ "support": {
+ "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
+ "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0"
+ },
+ "time": "2021-10-19T17:43:47+00:00"
+ },
+ {
+ "name": "phpdocumentor/type-resolver",
+ "version": "1.6.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpDocumentor/TypeResolver.git",
+ "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
+ "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.4 || ^8.0",
+ "phpdocumentor/reflection-common": "^2.0"
+ },
+ "require-dev": {
+ "ext-tokenizer": "*",
+ "phpstan/extension-installer": "^1.1",
+ "phpstan/phpstan": "^1.8",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpunit/phpunit": "^9.5",
+ "rector/rector": "^0.13.9",
+ "vimeo/psalm": "^4.25"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-1.x": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "phpDocumentor\\Reflection\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Mike van Riel",
+ "email": "me@mikevanriel.com"
+ }
+ ],
+ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
+ "support": {
+ "issues": "https://github.com/phpDocumentor/TypeResolver/issues",
+ "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2"
+ },
+ "time": "2022-10-14T12:47:21+00:00"
+ },
+ {
+ "name": "phpstan/phpdoc-parser",
+ "version": "1.16.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpdoc-parser.git",
+ "reference": "57090cfccbfaa639e703c007486d605a6e80f56d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/57090cfccbfaa639e703c007486d605a6e80f56d",
+ "reference": "57090cfccbfaa639e703c007486d605a6e80f56d",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0"
+ },
+ "require-dev": {
+ "php-parallel-lint/php-parallel-lint": "^1.2",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "^1.5",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpstan/phpstan-strict-rules": "^1.0",
+ "phpunit/phpunit": "^9.5",
+ "symfony/process": "^5.2"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\PhpDocParser\\": [
+ "src/"
+ ]
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPDoc parser with support for nullable, intersection and generic types",
+ "support": {
+ "issues": "https://github.com/phpstan/phpdoc-parser/issues",
+ "source": "https://github.com/phpstan/phpdoc-parser/tree/1.16.0"
+ },
+ "time": "2023-01-29T14:41:23+00:00"
+ },
{
"name": "psr/cache",
"version": "3.0.0",
@@ -4177,6 +4463,107 @@
],
"time": "2022-12-13T14:55:03+00:00"
},
+ {
+ "name": "symfony/serializer",
+ "version": "v6.2.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/serializer.git",
+ "reference": "dec3263bd7399f85cc54ea51a019e60b085759f0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/serializer/zipball/dec3263bd7399f85cc54ea51a019e60b085759f0",
+ "reference": "dec3263bd7399f85cc54ea51a019e60b085759f0",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "symfony/polyfill-ctype": "~1.8"
+ },
+ "conflict": {
+ "doctrine/annotations": "<1.12",
+ "phpdocumentor/reflection-docblock": "<3.2.2",
+ "phpdocumentor/type-resolver": "<1.4.0|>=1.7.0",
+ "symfony/dependency-injection": "<5.4",
+ "symfony/property-access": "<5.4",
+ "symfony/property-info": "<5.4",
+ "symfony/uid": "<5.4",
+ "symfony/yaml": "<5.4"
+ },
+ "require-dev": {
+ "doctrine/annotations": "^1.12|^2",
+ "phpdocumentor/reflection-docblock": "^3.2|^4.0|^5.0",
+ "symfony/cache": "^5.4|^6.0",
+ "symfony/config": "^5.4|^6.0",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/error-handler": "^5.4|^6.0",
+ "symfony/filesystem": "^5.4|^6.0",
+ "symfony/form": "^5.4|^6.0",
+ "symfony/http-foundation": "^5.4|^6.0",
+ "symfony/http-kernel": "^5.4|^6.0",
+ "symfony/mime": "^5.4|^6.0",
+ "symfony/property-access": "^5.4|^6.0",
+ "symfony/property-info": "^5.4|^6.0",
+ "symfony/uid": "^5.4|^6.0",
+ "symfony/validator": "^5.4|^6.0",
+ "symfony/var-dumper": "^5.4|^6.0",
+ "symfony/var-exporter": "^5.4|^6.0",
+ "symfony/yaml": "^5.4|^6.0"
+ },
+ "suggest": {
+ "psr/cache-implementation": "For using the metadata cache.",
+ "symfony/config": "For using the XML mapping loader.",
+ "symfony/mime": "For using a MIME type guesser within the DataUriNormalizer.",
+ "symfony/property-access": "For using the ObjectNormalizer.",
+ "symfony/property-info": "To deserialize relations.",
+ "symfony/var-exporter": "For using the metadata compiler.",
+ "symfony/yaml": "For using the default YAML mapping loader."
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Serializer\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/serializer/tree/v6.2.5"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-01-20T17:45:48+00:00"
+ },
{
"name": "symfony/service-contracts",
"version": "v3.2.0",
@@ -4692,6 +5079,64 @@
"source": "https://github.com/SymfonyCasts/verify-email-bundle/tree/v1.13.0"
},
"time": "2023-01-04T12:46:15+00:00"
+ },
+ {
+ "name": "webmozart/assert",
+ "version": "1.11.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/webmozarts/assert.git",
+ "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991",
+ "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991",
+ "shasum": ""
+ },
+ "require": {
+ "ext-ctype": "*",
+ "php": "^7.2 || ^8.0"
+ },
+ "conflict": {
+ "phpstan/phpstan": "<0.12.20",
+ "vimeo/psalm": "<4.6.1 || 4.6.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^8.5.13"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.10-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Webmozart\\Assert\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Bernhard Schussek",
+ "email": "bschussek@gmail.com"
+ }
+ ],
+ "description": "Assertions to validate method input/output with nice error messages.",
+ "keywords": [
+ "assert",
+ "check",
+ "validate"
+ ],
+ "support": {
+ "issues": "https://github.com/webmozarts/assert/issues",
+ "source": "https://github.com/webmozarts/assert/tree/1.11.0"
+ },
+ "time": "2022-06-03T18:03:27+00:00"
}
],
"packages-dev": [
diff --git a/config/packages/security.yaml b/config/packages/security.yaml
index 5844f17..9566704 100644
--- a/config/packages/security.yaml
+++ b/config/packages/security.yaml
@@ -35,7 +35,7 @@ security:
access_control:
# - { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/api/acc/*, roles: ROLE_USER }
-
+ - { path: ^/api/app/*, roles: ROLE_USER }
when@test:
security:
password_hashers:
diff --git a/src/Controller/BlogController.php b/src/Controller/BlogController.php
new file mode 100644
index 0000000..8bfaa3c
--- /dev/null
+++ b/src/Controller/BlogController.php
@@ -0,0 +1,22 @@
+json([
+ 'error' => 0,
+ 'data' => $serializer->serialize($entityManager->getRepository(BlogCat::class)->findAll(),'json'),
+ ]);
+ }
+}
diff --git a/src/Controller/GuideController.php b/src/Controller/GuideController.php
new file mode 100644
index 0000000..c070025
--- /dev/null
+++ b/src/Controller/GuideController.php
@@ -0,0 +1,124 @@
+getRepository(GuideContent::class)->findBy(['cat'=>$id]);
+ $res=[];
+ foreach($lists as $list){
+ $tmp = [];
+ $tmp['title'] = $list->getTitle();
+ $tmp['url'] = $list->getUrl();
+ $res[] = $tmp;
+ }
+ return $this->json($res);
+ }
+ #[Route('/api/guide/get/content/{id}', name: 'app_guide_get_content')]
+ public function app_guide_get_content($id,EntityManagerInterface $entityManager): JsonResponse
+ {
+ $content = $entityManager->getRepository(GuideContent::class)->findOneBy(['url'=>$id]);
+ return $this->json([
+ 'title'=> $content->getTitle(),
+ 'body'=> $content->getBody(),
+ 'url'=>$content->getUrl(),
+ 'cat'=>$content->getCat()
+ ]);
+ }
+
+ #[Route('/api/guide/update/content/{id}', name: 'app_guide_update_content')]
+ public function app_guide_update_content($id,Request $request, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $guide = $entityManager->getRepository(GuideContent::class)->findOneBy(['url'=>$id]);
+ if(is_null($guide))
+ throw $this->createNotFoundException();
+
+ $params = [];
+ if ($content = $request->getContent()) {
+ $params = json_decode($content, true);
+ }
+ if(array_key_exists('title',$params) && array_key_exists('cat',$params) && array_key_exists('body',$params )){
+ if($entityManager->getRepository(GuideContent::class)->findOneBy(['url'=>$params['url']]) && $params['url'] != $id){
+ return $this->json([
+ 'error'=> 1,
+ 'message'=> 'این پیوند قبلا ثبت شده است.'
+ ]);
+ }
+
+ $guide->setBody($params['body']);
+ $guide->setCat($params['cat']);
+ $guide->setTitle($params['title']);
+ $guide->setDateSubmit(time());
+ $guide->setSubmiter($this->getUser());
+ if($id != 'home')
+ $guide->setUrl(str_replace(' ','_',$params['url']));
+ $entityManager->persist($guide);
+ $entityManager->flush();
+ return $this->json([
+ 'error'=> 0,
+ 'message'=> 'ok',
+ 'url'=>$guide->getUrl()
+ ]);
+ }
+ return $this->json([
+ 'error'=> 999,
+ 'message'=> 'تمام موارد لازم را وارد کنید.'
+ ]);
+ }
+
+ #[Route('/api/guide/insert', name: 'app_guide_insert')]
+ public function app_guide_insert(Request $request,EntityManagerInterface $entityManager): JsonResponse
+ {
+ $params = [];
+ if ($content = $request->getContent()) {
+ $params = json_decode($content, true);
+ }
+ if(array_key_exists('title',$params) && array_key_exists('cat',$params) && array_key_exists('body',$params )){
+ if($entityManager->getRepository(GuideContent::class)->findOneBy(['url'=>$params['url']])){
+ return $this->json([
+ 'error'=> 1,
+ 'message'=> 'این پیوند قبلا ثبت شده است.'
+ ]);
+ }
+ $guide = new GuideContent();
+ $guide->setBody($params['body']);
+ $guide->setCat($params['cat']);
+ $guide->setTitle($params['title']);
+ $guide->setDateSubmit(time());
+ $guide->setSubmiter($this->getUser());
+ $guide->setUrl(str_replace(' ','_',$params['url']));
+ $entityManager->persist($guide);
+ $entityManager->flush();
+ return $this->json([
+ 'error'=> 0,
+ 'message'=> 'ok',
+ 'url'=>$guide->getUrl()
+ ]);
+ }
+ return $this->json([
+ 'error'=> 999,
+ 'message'=> 'تمام موارد لازم را وارد کنید.'
+ ]);
+ }
+ #[Route('/api/guide/delete/{id}', name: 'app_guide_delete')]
+ public function app_guide_delete($id,Request $request,EntityManagerInterface $entityManager): JsonResponse
+ {
+ $content = $entityManager->getRepository(GuideContent::class)->findOneBy(['url'=>$id]);
+ if($content && $content->getUrl() != 'home')
+ $entityManager->getRepository(GuideContent::class)->remove($content,true);
+ return $this->json([
+ 'error'=> 0,
+ 'message'=> 'ok',
+ ]);
+ }
+}
diff --git a/src/Controller/StackController.php b/src/Controller/StackController.php
new file mode 100644
index 0000000..77430d8
--- /dev/null
+++ b/src/Controller/StackController.php
@@ -0,0 +1,309 @@
+getRepository(StackCat::class)->findAll();
+ foreach ($cats as $cat){
+ $temp = [];
+ $temp['id'] = $cat->getId();
+ $temp['name'] = $cat->getName();
+ $temp['code'] = $cat->getCode();
+ $result[] = $temp;
+ }
+ return $this->json($result);
+ }
+ #[Route('/api/stack/insert', name: 'app_stack_content_insert')]
+ public function app_stack_content_insert(Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $params = [];
+ if ($content = $request->getContent()) {
+ $params = json_decode($content, true);
+ }
+ if(array_key_exists('title',$params) && array_key_exists('cat',$params) && array_key_exists('body',$params )){
+ $cat = $entityManager->getRepository(StackCat::class)->find($params['cat']);
+ $stack = new StackContent();
+ $stack->setBody($params['body']);
+ $stack->setCat($cat);
+ $stack->setTitle($params['title']);
+ $stack->setDateSubmit(time());
+ $stack->setViews(0);
+ $stack->setSubmitter($this->getUser());
+ $stack->setUrl(str_replace(' ','_',$params['title']));
+ $entityManager->persist($stack);
+ $entityManager->flush();
+ return $this->json([
+ 'error'=> 0,
+ 'message'=> 'ok',
+ 'url'=>$stack->getUrl()
+ ]);
+ }
+ return $this->json([
+ 'error'=> 999,
+ 'message'=> 'تمام موارد لازم را وارد کنید.'
+ ]);
+ }
+
+ #[Route('/api/stack/replay/insert', name: 'app_stack_replay_insert')]
+ public function app_stack_replay_insert(Jdate $jdate,Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $params = [];
+ if ($content = $request->getContent()) {
+ $params = json_decode($content, true);
+ }
+ if( array_key_exists('upper',$params) && array_key_exists('body',$params )){
+ $upper = $entityManager->getRepository(StackContent::class)->findOneBy(['url'=>$params['upper']]);
+ if(!$upper)
+ throw $this->createNotFoundException();
+ $stack = new StackContent();
+ $stack->setUpper($upper);
+ $stack->setBody($params['body']);
+ $stack->setCat($upper->getCat());
+ $stack->setTitle('پاسخ به: ' . $upper->getTitle());
+ $stack->setDateSubmit(time());
+ $stack->setViews(0);
+ $stack->setSubmitter($this->getUser());
+ $stack->setUrl('0');
+ $entityManager->persist($stack);
+ $entityManager->flush();
+ return $this->json([
+ 'error'=> 0,
+ 'message'=> 'ok',
+ 'url'=>$stack->getUrl(),
+ 'data'=>[
+ 'id'=> $stack->getId(),
+ 'title' => $stack->getTitle(),
+ 'body' => $stack->getBody(),
+ 'submitter' => $stack->getSubmitter()->getFullName(),
+ 'dateSubmit' => $jdate->pastTime($stack->getDateSubmit()),
+ 'cat' => $stack->getCat()->getName(),
+ 'views' => $stack->getViews(),
+ 'url' => $stack->getUrl(),
+ 'submitter_gravatar_hash' => $provider->gravatarHash($stack->getSubmitter()->getEmail())
+ ]
+ ]);
+ }
+ return $this->json([
+ 'error'=> 999,
+ 'message'=> 'تمام موارد لازم را وارد کنید.',
+ ]);
+ }
+
+ /**
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ * @throws \Doctrine\ORM\NoResultException
+ */
+ #[Route('/api/stack/contents/search', name: 'app_stack_contents_get')]
+ public function app_stack_contents_get(Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $params = [];
+ if ($content = $request->getContent()) {
+ $params = json_decode($content, true);
+ }
+ $params = $provider->createSearchParams($request);
+ $items = $entityManager->getRepository(StackContent::class)->search($params);
+ $response = [];
+ foreach ($items as $item){
+ $temp = [];
+ $temp['id'] = $item->getId();
+ $temp['title'] = $item->getTitle();
+ $temp['body'] = $item->getBody();
+ $temp['submitter'] = $item->getSubmitter()->getFullName();
+ $temp['dateSubmit'] = $jdate->pastTime($item->getDateSubmit());
+ $temp['cat'] = $item->getCat()->getName();
+ $temp['views'] = $item->getViews();
+ $temp['url'] = $item->getUrl();
+ $temp['replaysCount'] = $entityManager->getRepository(StackContent::class)->getCountReplaysOfQuestion($item);
+ $replays = $entityManager->getRepository(StackContent::class)->getReplaysOfQuestion($item);
+ $temp['lastReplayPerson'] = '';
+ $temp['lastReplayDate'] = '';
+ if(count($replays) != 0){
+ $temp['lastReplayPerson'] = $replays[0]->getSubmitter()->getFullName();
+ $temp['lastReplayDate'] = $jdate->pastTime($replays[0]->getDateSubmit());
+ }
+ $response[] = $temp;
+ }
+ return $this->json($response);
+ }
+
+ #[Route('/api/stack/replays/search/{url}', name: 'app_stack_replays_get')]
+ public function app_stack_replays_get($url,Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $upper = $entityManager->getRepository(StackContent::class)->findOneBy(['url'=>$url]);
+ if(!$upper)
+ throw $this->createNotFoundException();
+ $items = $entityManager->getRepository(StackContent::class)->findBy(
+ [
+ 'upper'=>$upper,
+ ]
+ );
+ $response = [];
+ foreach ($items as $item){
+ $temp = [];
+ $temp['id'] = $item->getId();
+ $temp['title'] = $item->getTitle();
+ $temp['body'] = $item->getBody();
+ $temp['submitter'] = $item->getSubmitter()->getFullName();
+ $temp['dateSubmit'] = $jdate->pastTime($item->getDateSubmit());
+ $temp['cat'] = $item->getCat()->getName();
+ $temp['views'] = $item->getViews();
+ $temp['url'] = $item->getUrl();
+ $temp['submitter_gravatar_hash'] = $provider->gravatarHash($item->getSubmitter()->getEmail());
+ $response[] = $temp;
+ }
+ return $this->json($response);
+ }
+
+ #[Route('/api/stack/content/get/{url}', name: 'app_stack_content_get')]
+ public function app_stack_content_get($url,Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $item = $entityManager->getRepository(StackContent::class)->findOneBy(['url'=>$url]);
+ if(!$item)
+ throw $this->createNotFoundException();
+ $response = [];
+ $response['id'] = $item->getId();
+ $response['title'] = $item->getTitle();
+ $response['body'] = $item->getBody();
+ $response['submitter'] = $item->getSubmitter()->getFullName();
+ $response['dateSubmit'] = $jdate->pastTime($item->getDateSubmit());
+ $response['cat'] = $item->getCat()->getName();
+ $response['views'] = $item->getViews();
+ $response['url'] = $url;
+ $response['submitter_gravatar_hash'] = $provider->gravatarHash($item->getSubmitter()->getEmail());
+ return $this->json($response);
+ }
+ #[Route('/api/stack/content/getbyid/{id}', name: 'app_stack_content_get_by_id')]
+ public function app_stack_content_get_by_id($id,Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $item = $entityManager->getRepository(StackContent::class)->find($id);
+ if(!$item)
+ throw $this->createNotFoundException();
+ $response = [];
+ $response['id'] = $item->getId();
+ $response['title'] = $item->getTitle();
+ $response['body'] = $item->getBody();
+ $response['submitter'] = $item->getSubmitter()->getFullName();
+ $response['dateSubmit'] = $jdate->pastTime($item->getDateSubmit());
+ $response['cat'] = $item->getCat()->getName();
+ $response['views'] = $item->getViews();
+ $response['url'] = $item->getUrl();
+ $response['submitter_gravatar_hash'] = $provider->gravatarHash($item->getSubmitter()->getEmail());
+ return $this->json($response);
+ }
+ #[Route('/api/stack/content/increase/view/{url}', name: 'app_stack_content_increase_view')]
+ public function app_stack_content_increase_view($url,Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $item = $entityManager->getRepository(StackContent::class)->findOneBy(['url'=>$url]);
+ $item->setViews($item->getViews() + 1);
+ $entityManager->persist($item);
+ $entityManager->flush();
+ return $this->json([
+ 'error' => 0,
+ 'result' => 'ok'
+ ]);
+ }
+
+ #[Route('/api/stack/stat/get', name: 'app_stack_stat_get')]
+ public function app_stack_stat_get(Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+
+ $response = [];
+ $response['replayCount'] = $entityManager->getRepository(StackContent::class)->getAllReplayCount();
+ $response['questionCount'] = $entityManager->getRepository(StackContent::class)->getStackCount();;
+ return $this->json($response);
+ }
+
+ #[Route('/api/stack/content/delete/{url}', name: 'app_stack_content_delete')]
+ public function app_stack_content_delete($url,Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $content = $entityManager->getRepository(StackContent::class)->findOneBy(['url'=>$url]);
+ if(!$content)
+ throw $this->createNotFoundException();
+ if($content->getSubmitter() === $this->getUser()){
+ if(! $content->getUpper()){
+ $items = $entityManager->getRepository(StackContent::class)->findBy([
+ 'upper'=>$content,
+ ]);
+ foreach ($items as $item){
+ $entityManager->getRepository(StackContent::class)->remove($item,true);
+ }
+ }
+ $entityManager->getRepository(StackContent::class)->remove($content,true);
+ return $this->json([
+ 'error' => 0,
+ 'result' => 'ok'
+ ]);
+ }
+ throw $this->createAccessDeniedException();
+ }
+
+ #[Route('/api/stack/content/deletebyid/{id}', name: 'app_stack_content_delete_by_id')]
+ public function app_stack_content_delete_by_id($id,Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $content = $entityManager->getRepository(StackContent::class)->find($id);
+ if(!$content)
+ throw $this->createNotFoundException();
+ if($content->getSubmitter() === $this->getUser()){
+ if(! $content->getUpper()){
+ $items = $entityManager->getRepository(StackContent::class)->findBy([
+ 'upper'=>$content,
+ ]);
+ foreach ($items as $item){
+ $entityManager->getRepository(StackContent::class)->remove($item,true);
+ }
+ }
+ $entityManager->getRepository(StackContent::class)->remove($content,true);
+ return $this->json([
+ 'error' => 0,
+ 'result' => 'ok'
+ ]);
+ }
+ throw $this->createAccessDeniedException();
+ }
+
+ #[Route('/api/stack/edit/{id}', name: 'app_stack_content_edit')]
+ public function app_stack_content_edit($id,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
+ {
+ $params = [];
+ if ($content = $request->getContent()) {
+ $params = json_decode($content, true);
+ }
+ if(array_key_exists('title',$params) && array_key_exists('cat',$params) && array_key_exists('body',$params )){
+ $stack = $entityManager->getRepository(StackContent::class)->find($id);
+ if(! $stack)
+ throw $this->createNotFoundException();
+ $cat = $entityManager->getRepository(StackCat::class)->find($params['cat']);
+ $stack->setBody($params['body']);
+ $stack->setCat($cat);
+ $stack->setTitle($params['title']);
+ $entityManager->persist($stack);
+ $entityManager->flush();
+ return $this->json([
+ 'error'=> 0,
+ 'message'=> 'ok',
+ 'url'=>$stack->getUrl()
+ ]);
+ }
+ return $this->json([
+ 'error'=> 999,
+ 'message'=> 'تمام موارد لازم را وارد کنید.'
+ ]);
+ }
+}
diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php
index f443832..5e2810e 100644
--- a/src/Controller/UserController.php
+++ b/src/Controller/UserController.php
@@ -1,6 +1,7 @@
json([
+ 'message' => 'missing credentials',
+ ], Response::HTTP_UNAUTHORIZED);
+ }
+ return $this->json(
+ ['is_login'=>true]
+ );
+ }
+
#[Route('/api/user/current/info', name: 'api_user_current_info')]
- public function api_user_current_info(#[CurrentUser] ?User $user,EntityManagerInterface $entityManager): Response
+ public function api_user_current_info(#[CurrentUser] ?User $user,Provider $provider,EntityManagerInterface $entityManager): Response
{
return $this->json([
'email'=>$user->getEmail(),
'fullname'=>$user->getFullName(),
- 'businessCount'=>count($user->getBusinesses())
+ 'businessCount'=>count($user->getBusinesses()),
+ 'hash_email'=> $provider->gravatarHash($user->getEmail())
]);
}
@@ -114,13 +129,42 @@ class UserController extends AbstractController
return $this->json(['result'=>true]);
}
+ #[Route('/api/user/is_superadmin', name: 'api_user_is_super_admin')]
+ public function api_user_is_super_admin(#[CurrentUser] ?User $user,EntityManagerInterface $entityManager,Request $request): Response
+ {
+ $this->denyAccessUnlessGranted('ROLE_ADMIN');
+ return $this->json(['result'=>1]);
+ }
+
+ #[Route('/api/user/change/password', name: 'api_user_change_password')]
+ public function api_user_change_password(#[CurrentUser] ?User $user,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
+ {
+ $params = [];
+ if ($content = $request->getContent()) {
+ $params = json_decode($content, true);
+ }
+ if($params['pass'] == $params['repass']){
+ $user->setPassword(
+ $userPasswordHasher->hashPassword(
+ $user,
+ $params['pass']
+ )
+ );
+ $entityManager->persist($user);
+ $entityManager->flush();
+ return $this->json(['result'=>true]);
+ }
+ return $this->json(['result'=>false]);
+ }
#[Route('/api/user/register', name: 'api_user_register')]
public function api_user_register(Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager): Response
{
$user = new User();
- $user->setEmail('alizadeh.babak@gmail.com');
- $user->setRoles([]);
+ $user->setEmail('alizadeh.babak@gmail.com1');
+ $user->setRoles(['ROLE_ADMIN']);
+ $user->setFullName('babak');
+ $user->setDateRegister(time());
$user->setPassword(
$userPasswordHasher->hashPassword(
$user,
diff --git a/src/Entity/BlogCat.php b/src/Entity/BlogCat.php
new file mode 100644
index 0000000..f465e2b
--- /dev/null
+++ b/src/Entity/BlogCat.php
@@ -0,0 +1,50 @@
+id;
+ }
+
+ public function getLabel(): ?string
+ {
+ return $this->label;
+ }
+
+ public function setLabel(string $label): self
+ {
+ $this->label = $label;
+
+ return $this;
+ }
+
+ public function getCode(): ?string
+ {
+ return $this->code;
+ }
+
+ public function setCode(string $code): self
+ {
+ $this->code = $code;
+
+ return $this;
+ }
+}
diff --git a/src/Entity/GuideContent.php b/src/Entity/GuideContent.php
new file mode 100644
index 0000000..4328899
--- /dev/null
+++ b/src/Entity/GuideContent.php
@@ -0,0 +1,112 @@
+id;
+ }
+
+ public function getCat(): ?string
+ {
+ return $this->cat;
+ }
+
+ public function setCat(string $cat): self
+ {
+ $this->cat = $cat;
+
+ return $this;
+ }
+
+ public function getTitle(): ?string
+ {
+ return $this->title;
+ }
+
+ public function setTitle(string $title): self
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
+ public function getBody(): ?string
+ {
+ return $this->body;
+ }
+
+ public function setBody(?string $body): self
+ {
+ $this->body = $body;
+
+ return $this;
+ }
+
+ public function getSubmiter(): ?User
+ {
+ return $this->submiter;
+ }
+
+ public function setSubmiter(?User $submiter): self
+ {
+ $this->submiter = $submiter;
+
+ return $this;
+ }
+
+ public function getDateSubmit(): ?string
+ {
+ return $this->dateSubmit;
+ }
+
+ public function setDateSubmit(string $dateSubmit): self
+ {
+ $this->dateSubmit = $dateSubmit;
+
+ return $this;
+ }
+
+ public function getUrl(): ?string
+ {
+ return $this->url;
+ }
+
+ public function setUrl(string $url): self
+ {
+ $this->url = $url;
+
+ return $this;
+ }
+}
diff --git a/src/Entity/StackCat.php b/src/Entity/StackCat.php
new file mode 100644
index 0000000..eaaf864
--- /dev/null
+++ b/src/Entity/StackCat.php
@@ -0,0 +1,90 @@
+stackContents = new ArrayCollection();
+ }
+
+ public function getId(): ?int
+ {
+ return $this->id;
+ }
+
+ public function getName(): ?string
+ {
+ return $this->name;
+ }
+
+ public function setName(string $name): self
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ public function getCode(): ?string
+ {
+ return $this->code;
+ }
+
+ public function setCode(string $code): self
+ {
+ $this->code = $code;
+
+ return $this;
+ }
+
+ /**
+ * @return Collection
+ */
+ public function getStackContents(): Collection
+ {
+ return $this->stackContents;
+ }
+
+ public function addStackContent(StackContent $stackContent): self
+ {
+ if (!$this->stackContents->contains($stackContent)) {
+ $this->stackContents->add($stackContent);
+ $stackContent->setCat($this);
+ }
+
+ return $this;
+ }
+
+ public function removeStackContent(StackContent $stackContent): self
+ {
+ if ($this->stackContents->removeElement($stackContent)) {
+ // set the owning side to null (unless already changed)
+ if ($stackContent->getCat() === $this) {
+ $stackContent->setCat(null);
+ }
+ }
+
+ return $this;
+ }
+}
diff --git a/src/Entity/StackContent.php b/src/Entity/StackContent.php
new file mode 100644
index 0000000..4f9a211
--- /dev/null
+++ b/src/Entity/StackContent.php
@@ -0,0 +1,143 @@
+id;
+ }
+
+ public function getSubmitter(): ?User
+ {
+ return $this->submitter;
+ }
+
+ public function setSubmitter(?User $submitter): self
+ {
+ $this->submitter = $submitter;
+
+ return $this;
+ }
+
+ public function getDateSubmit(): ?string
+ {
+ return $this->dateSubmit;
+ }
+
+ public function setDateSubmit(string $dateSubmit): self
+ {
+ $this->dateSubmit = $dateSubmit;
+
+ return $this;
+ }
+
+ public function getCat(): ?StackCat
+ {
+ return $this->cat;
+ }
+
+ public function setCat(?StackCat $cat): self
+ {
+ $this->cat = $cat;
+
+ return $this;
+ }
+
+ public function getTitle(): ?string
+ {
+ return $this->title;
+ }
+
+ public function setTitle(string $title): self
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
+ public function getBody(): ?string
+ {
+ return $this->body;
+ }
+
+ public function setBody(string $body): self
+ {
+ $this->body = $body;
+
+ return $this;
+ }
+
+ public function getViews(): ?string
+ {
+ return $this->views;
+ }
+
+ public function setViews(string $views): self
+ {
+ $this->views = $views;
+
+ return $this;
+ }
+
+ public function getUrl(): ?string
+ {
+ return $this->url;
+ }
+
+ public function setUrl(string $url): self
+ {
+ $this->url = $url;
+
+ return $this;
+ }
+
+ public function getUpper(): ?self
+ {
+ return $this->upper;
+ }
+
+ public function setUpper(?self $upper): self
+ {
+ $this->upper = $upper;
+
+ return $this;
+ }
+}
diff --git a/src/Entity/User.php b/src/Entity/User.php
index 966abd1..c78ba1c 100644
--- a/src/Entity/User.php
+++ b/src/Entity/User.php
@@ -21,7 +21,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private ?string $email = null;
#[ORM\Column]
- private array $roles = [];
+ private array $roles = ['ROLE_ADMIN'];
/**
* @var string The hashed password
@@ -41,10 +41,18 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Business::class, orphanRemoval: true)]
private Collection $businesses;
+ #[ORM\OneToMany(mappedBy: 'submiter', targetEntity: GuideContent::class, orphanRemoval: true)]
+ private Collection $guideContents;
+
+ #[ORM\OneToMany(mappedBy: 'submitter', targetEntity: StackContent::class, orphanRemoval: true)]
+ private Collection $stackContents;
+
public function __construct()
{
$this->userTokens = new ArrayCollection();
$this->businesses = new ArrayCollection();
+ $this->guideContents = new ArrayCollection();
+ $this->stackContents = new ArrayCollection();
}
public function getId(): ?int
@@ -200,4 +208,64 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this;
}
+
+ /**
+ * @return Collection
+ */
+ public function getGuideContents(): Collection
+ {
+ return $this->guideContents;
+ }
+
+ public function addGuideContent(GuideContent $guideContent): self
+ {
+ if (!$this->guideContents->contains($guideContent)) {
+ $this->guideContents->add($guideContent);
+ $guideContent->setSubmiter($this);
+ }
+
+ return $this;
+ }
+
+ public function removeGuideContent(GuideContent $guideContent): self
+ {
+ if ($this->guideContents->removeElement($guideContent)) {
+ // set the owning side to null (unless already changed)
+ if ($guideContent->getSubmiter() === $this) {
+ $guideContent->setSubmiter(null);
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return Collection
+ */
+ public function getStackContents(): Collection
+ {
+ return $this->stackContents;
+ }
+
+ public function addStackContent(StackContent $stackContent): self
+ {
+ if (!$this->stackContents->contains($stackContent)) {
+ $this->stackContents->add($stackContent);
+ $stackContent->setSubmitter($this);
+ }
+
+ return $this;
+ }
+
+ public function removeStackContent(StackContent $stackContent): self
+ {
+ if ($this->stackContents->removeElement($stackContent)) {
+ // set the owning side to null (unless already changed)
+ if ($stackContent->getSubmitter() === $this) {
+ $stackContent->setSubmitter(null);
+ }
+ }
+
+ return $this;
+ }
}
diff --git a/src/Repository/BlogCatRepository.php b/src/Repository/BlogCatRepository.php
new file mode 100644
index 0000000..f6de79d
--- /dev/null
+++ b/src/Repository/BlogCatRepository.php
@@ -0,0 +1,66 @@
+
+ *
+ * @method BlogCat|null find($id, $lockMode = null, $lockVersion = null)
+ * @method BlogCat|null findOneBy(array $criteria, array $orderBy = null)
+ * @method BlogCat[] findAll()
+ * @method BlogCat[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class BlogCatRepository extends ServiceEntityRepository
+{
+ public function __construct(ManagerRegistry $registry)
+ {
+ parent::__construct($registry, BlogCat::class);
+ }
+
+ public function save(BlogCat $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->persist($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+ public function remove(BlogCat $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->remove($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+// /**
+// * @return BlogCat[] Returns an array of BlogCat objects
+// */
+// public function findByExampleField($value): array
+// {
+// return $this->createQueryBuilder('b')
+// ->andWhere('b.exampleField = :val')
+// ->setParameter('val', $value)
+// ->orderBy('b.id', 'ASC')
+// ->setMaxResults(10)
+// ->getQuery()
+// ->getResult()
+// ;
+// }
+
+// public function findOneBySomeField($value): ?BlogCat
+// {
+// return $this->createQueryBuilder('b')
+// ->andWhere('b.exampleField = :val')
+// ->setParameter('val', $value)
+// ->getQuery()
+// ->getOneOrNullResult()
+// ;
+// }
+}
diff --git a/src/Repository/GuideContentRepository.php b/src/Repository/GuideContentRepository.php
new file mode 100644
index 0000000..f8d849f
--- /dev/null
+++ b/src/Repository/GuideContentRepository.php
@@ -0,0 +1,66 @@
+
+ *
+ * @method GuideContent|null find($id, $lockMode = null, $lockVersion = null)
+ * @method GuideContent|null findOneBy(array $criteria, array $orderBy = null)
+ * @method GuideContent[] findAll()
+ * @method GuideContent[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class GuideContentRepository extends ServiceEntityRepository
+{
+ public function __construct(ManagerRegistry $registry)
+ {
+ parent::__construct($registry, GuideContent::class);
+ }
+
+ public function save(GuideContent $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->persist($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+ public function remove(GuideContent $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->remove($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+// /**
+// * @return GuideContent[] Returns an array of GuideContent objects
+// */
+// public function findByExampleField($value): array
+// {
+// return $this->createQueryBuilder('g')
+// ->andWhere('g.exampleField = :val')
+// ->setParameter('val', $value)
+// ->orderBy('g.id', 'ASC')
+// ->setMaxResults(10)
+// ->getQuery()
+// ->getResult()
+// ;
+// }
+
+// public function findOneBySomeField($value): ?GuideContent
+// {
+// return $this->createQueryBuilder('g')
+// ->andWhere('g.exampleField = :val')
+// ->setParameter('val', $value)
+// ->getQuery()
+// ->getOneOrNullResult()
+// ;
+// }
+}
diff --git a/src/Repository/StackCatRepository.php b/src/Repository/StackCatRepository.php
new file mode 100644
index 0000000..cf2bc2f
--- /dev/null
+++ b/src/Repository/StackCatRepository.php
@@ -0,0 +1,66 @@
+
+ *
+ * @method StackCat|null find($id, $lockMode = null, $lockVersion = null)
+ * @method StackCat|null findOneBy(array $criteria, array $orderBy = null)
+ * @method StackCat[] findAll()
+ * @method StackCat[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class StackCatRepository extends ServiceEntityRepository
+{
+ public function __construct(ManagerRegistry $registry)
+ {
+ parent::__construct($registry, StackCat::class);
+ }
+
+ public function save(StackCat $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->persist($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+ public function remove(StackCat $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->remove($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+// /**
+// * @return StackCat[] Returns an array of StackCat objects
+// */
+// public function findByExampleField($value): array
+// {
+// return $this->createQueryBuilder('s')
+// ->andWhere('s.exampleField = :val')
+// ->setParameter('val', $value)
+// ->orderBy('s.id', 'ASC')
+// ->setMaxResults(10)
+// ->getQuery()
+// ->getResult()
+// ;
+// }
+
+// public function findOneBySomeField($value): ?StackCat
+// {
+// return $this->createQueryBuilder('s')
+// ->andWhere('s.exampleField = :val')
+// ->setParameter('val', $value)
+// ->getQuery()
+// ->getOneOrNullResult()
+// ;
+// }
+}
diff --git a/src/Repository/StackContentRepository.php b/src/Repository/StackContentRepository.php
new file mode 100644
index 0000000..7668e73
--- /dev/null
+++ b/src/Repository/StackContentRepository.php
@@ -0,0 +1,112 @@
+
+ *
+ * @method StackContent|null find($id, $lockMode = null, $lockVersion = null)
+ * @method StackContent|null findOneBy(array $criteria, array $orderBy = null)
+ * @method StackContent[] findAll()
+ * @method StackContent[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class StackContentRepository extends ServiceEntityRepository
+{
+ public function __construct(ManagerRegistry $registry)
+ {
+ parent::__construct($registry, StackContent::class);
+ }
+
+ public function save(StackContent $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->persist($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+ public function remove(StackContent $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->remove($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+ /*
+ * @return StackContent[]
+ */
+ public function search($params): array
+ {
+ return $this->createQueryBuilder('s')
+ ->setMaxResults($params['count'])
+ ->setFirstResult(($params['page'] -1) * $params['count'])
+ ->orWhere('s.body LIKE :key')
+ ->andWhere('s.upper is NULL')
+ ->orderBy('s.id', 'DESC')
+ ->setParameter('key','%' . $params['key'] . '%')
+ ->getQuery()
+ ->getResult()
+ ;
+ }
+
+ /**
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ * @throws \Doctrine\ORM\NoResultException
+ */
+ public function getStackCount(): int{
+ return $this->createQueryBuilder('s')
+ ->select('count(s.id)')
+ ->andWhere('s.upper is NULL')
+ ->getQuery()
+ ->getSingleScalarResult()
+ ;
+ }
+ /**
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ * @throws \Doctrine\ORM\NoResultException
+ */
+ public function getAllReplayCount(): int{
+ return $this->createQueryBuilder('s')
+ ->select('count(s.id)')
+ ->andWhere('s.upper IS NOT NULL')
+ ->getQuery()
+ ->getSingleScalarResult()
+ ;
+ }
+
+ /**
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ * @throws \Doctrine\ORM\NoResultException
+ */
+ public function getCountReplaysOfQuestion(StackContent $upper): int{
+ return $this->createQueryBuilder('s')
+ ->select('count(s.id)')
+ ->andWhere('s.upper = :upper')
+ ->setParameter('upper' , $upper)
+ ->getQuery()
+ ->getSingleScalarResult()
+ ;
+ }
+
+ /**
+ * @throws \Doctrine\ORM\NonUniqueResultException
+ * @throws \Doctrine\ORM\NoResultException
+ */
+ public function getReplaysOfQuestion(StackContent $upper): array{
+ return $this->createQueryBuilder('s')
+ ->select('s')
+ ->andWhere('s.upper = :upper')
+ ->setParameter('upper' , $upper)
+ ->getQuery()
+ ->getResult()
+ ;
+ }
+
+}
diff --git a/src/Service/Jdate.php b/src/Service/Jdate.php
new file mode 100644
index 0000000..d50a333
--- /dev/null
+++ b/src/Service/Jdate.php
@@ -0,0 +1,595 @@
+jdate('Y/m/d',time());
+ }
+ public function time(){
+ return time();
+ }
+ public function fa2en($string) {
+ return strtr($string, array('۰'=>'0', '۱'=>'1', '۲'=>'2', '۳'=>'3', '۴'=>'4', '۵'=>'5', '۶'=>'6', '۷'=>'7', '۸'=>'8', '۹'=>'9', '٠'=>'0', '١'=>'1', '٢'=>'2', '٣'=>'3', '٤'=>'4', '٥'=>'5', '٦'=>'6', '٧'=>'7', '٨'=>'8', '٩'=>'9'));
+ }
+ public function jallaliToUnixTime($stringTime,$persianNum=true)
+ {
+ if($persianNum)
+ $stringTime = $this->fa2en($stringTime);
+ $ymd = explode('/',$stringTime);
+ $greDate = $this->jalali_to_gregorian($ymd[0],$ymd[1],$ymd[2]);
+ return strtotime($greDate[0].'/'.$greDate[1] . '/' .$greDate[2]);
+ }
+ /* F */
+ public function jdate($format,$timestamp='',$none='',$time_zone='Asia/Tehran',$tr_num='en'){
+ $T_sec=0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */
+ if($time_zone!='local')date_default_timezone_set(($time_zone==='')?'Asia/Tehran':$time_zone);
+ $ts=$T_sec+(($timestamp==='')?time():$this->tr_num($timestamp));
+ $date=explode('_',date('H_i_j_n_O_P_s_w_Y',$ts));
+ list($j_y,$j_m,$j_d)=$this->gregorian_to_jalali($date[8],$date[3],$date[2]);
+ $doy=($j_m<7)?(($j_m-1)*31)+$j_d-1:(($j_m-7)*30)+$j_d+185;
+ $kab=(((($j_y%33)%4)-1)==((int)(($j_y%33)*0.05)))?1:0;
+ $sl=strlen($format);
+ $out='';
+ for($i=0; $i<$sl; $i++){
+ $sub=substr($format,$i,1);
+ if($sub=='\\'){
+ $out.=substr($format,++$i,1);
+ continue;
+ }
+ switch($sub){
+ case'E':case'R':case'x':case'X':
+ $out.='http://jdf.scr.ir';
+ break;
+ case'B':case'e':case'g':
+ case'G':case'h':case'I':
+ case'T':case'u':case'Z':
+ $out.=date($sub,$ts);
+ break;
+ case'a':
+ $out.=($date[0]<12)?'ق.ظ':'ب.ظ';
+ break;
+ case'A':
+ $out.=($date[0]<12)?'قبل از ظهر':'بعد از ظهر';
+ break;
+ case'b':
+ $out.=(int)($j_m/3.1)+1;
+ break;
+ case'c':
+ $out.=$j_y.'/'.$j_m.'/'.$j_d.' ،'.$date[0].':'.$date[1].':'.$date[6].' '.$date[5];
+ break;
+ case'C':
+ $out.=(int)(($j_y+99)/100);
+ break;
+ case'd':
+ $out.=($j_d<10)?'0'.$j_d:$j_d;
+ break;
+ case'D':
+ $out.=$this->jdate_words(array('kh'=>$date[7]),' ');
+ break;
+ case'f':
+ $out.=$this->jdate_words(array('ff'=>$j_m),' ');
+ break;
+ case'F':
+ $out.=$this->jdate_words(array('mm'=>$j_m),' ');
+ break;
+ case'H':
+ $out.=$date[0];
+ break;
+ case'i':
+ $out.=$date[1];
+ break;
+ case'j':
+ $out.=$j_d;
+ break;
+ case'J':
+ $out.=$this->jdate_words(array('rr'=>$j_d),' ');
+ break;
+ case'k';
+ $out.=$this->tr_num(100-(int)($doy/($kab+365)*1000)/10,$$this->tr_num);
+ break;
+ case'K':
+ $out.=$this->tr_num((int)($doy/($kab+365)*1000)/10,$tr_num);
+ break;
+ case'l':
+ $out.=$this->jdate_words(array('rh'=>$date[7]),' ');
+ break;
+ case'L':
+ $out.=$kab;
+ break;
+ case'm':
+ $out.=$this->tr_num(($j_m>9)?$j_m:'0'.$j_m,$tr_num);
+ break;
+ case'M':
+ $out.=$this->jdate_words(array('km'=>$j_m),' ');
+ break;
+ case'n':
+ $out.=$j_m;
+ break;
+ case'N':
+ $out.=$date[7]+1;
+ break;
+ case'o':
+ $jdw=($date[7]==6)?0:$date[7]+1;
+ $dny=364+$kab-$doy;
+ $out.=($jdw>($doy+3) and $doy<3)?$j_y-1:(((3-$dny)>$jdw and $dny<3)?$j_y+1:$j_y);
+ break;
+ case'O':
+ $out.=$date[4];
+ break;
+ case'p':
+ $out.=$this->jdate_words(array('mb'=>$j_m),' ');
+ break;
+ case'P':
+ $out.=$date[5];
+ break;
+ case'q':
+ $out.=$this->jdate_words(array('sh'=>$j_y),' ');
+ break;
+ case'Q':
+ $out.=$kab+364-$doy;
+ break;
+ case'r':
+ $key=$this->jdate_words(array('rh'=>$date[7],'mm'=>$j_m));
+ $out.=$date[0].':'.$date[1].':'.$date[6].' '.$date[4].' '.$key['rh'].'، '.$j_d.' '.$key['mm'].' '.$j_y;
+ break;
+ case's':
+ $out.=$date[6];
+ break;
+ case'S':
+ $out.='ام';
+ break;
+ case't':
+ $out.=($j_m!=12)?(31-(int)($j_m/6.5)):($kab+29);
+ break;
+ case'U':
+ $out.=$ts;
+ break;
+ case'v':
+ $out.=$this->jdate_words(array('ss'=>($j_y%100)),' ');
+ break;
+ case'V':
+ $out.=$this->jdate_words(array('ss'=>$j_y),' ');
+ break;
+ case'w':
+ $out.=($date[7]==6)?0:$date[7]+1;
+ break;
+ case'W':
+ $avs=(($date[7]==6)?0:$date[7]+1)-($doy%7);
+ if($avs<0)$avs+=7;
+ $num=(int)(($doy+$avs)/7);
+ if($avs<4){
+ $num++;
+ }elseif($num<1){
+ $num=($avs==4 or $avs==((((($j_y%33)%4)-2)==((int)(($j_y%33)*0.05)))?5:4))?53:52;
+ }
+ $aks=$avs+$kab;
+ if($aks==7)$aks=0;
+ $out.=(($kab+363-$doy)<$aks and $aks<3)?'01':(($num<10)?'0'.$num:$num);
+ break;
+ case'y':
+ $out.=substr($j_y,2,2);
+ break;
+ case'Y':
+ $out.=$j_y;
+ break;
+ case'z':
+ $out.=$doy;
+ break;
+ default:$out.=$sub;
+ }
+ }
+ return($tr_num!='en')?$this->tr_num($out,'fa','.'):$out;
+ }
+ /* F */
+ public function jstrftime($format,$timestamp='',$none='',$time_zone='Asia/Tehran',$tr_num='fa'){
+ $T_sec=0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */
+ if($time_zone!='local')date_default_timezone_set(($time_zone==='')?'Asia/Tehran':$time_zone);
+ $ts=$T_sec+(($timestamp==='')?time():tr_num($timestamp));
+ $date=explode('_',date('h_H_i_j_n_s_w_Y',$ts));
+ list($j_y,$j_m,$j_d)=$this->gregorian_to_jalali($date[7],$date[4],$date[3]);
+ $doy=($j_m<7)?(($j_m-1)*31)+$j_d-1:(($j_m-7)*30)+$j_d+185;
+ $kab=(((($j_y%33)%4)-1)==((int)(($j_y%33)*0.05)))?1:0;
+ $sl=strlen($format);
+ $out='';
+ for($i=0; $i<$sl; $i++){
+ $sub=substr($format,$i,1);
+ if($sub=='%'){
+ $sub=substr($format,++$i,1);
+ }else{
+ $out.=$sub;
+ continue;
+ }
+ switch($sub){
+ /* Day */
+ case'a':
+ $out.=$this->jdate_words(array('kh'=>$date[6]),' ');
+ break;
+ case'A':
+ $out.=$this->jdate_words(array('rh'=>$date[6]),' ');
+ break;
+ case'd':
+ $out.=($j_d<10)?'0'.$j_d:$j_d;
+ break;
+ case'e':
+ $out.=($j_d<10)?' '.$j_d:$j_d;
+ break;
+ case'j':
+ $out.=str_pad($doy+1,3,0,STR_PAD_LEFT);
+ break;
+ case'u':
+ $out.=$date[6]+1;
+ break;
+ case'w':
+ $out.=($date[6]==6)?0:$date[6]+1;
+ break;
+ /* Week */
+ case'U':
+ $avs=(($date[6]<5)?$date[6]+2:$date[6]-5)-($doy%7);
+ if($avs<0)$avs+=7;
+ $num=(int)(($doy+$avs)/7)+1;
+ if($avs>3 or $avs==1)$num--;
+ $out.=($num<10)?'0'.$num:$num;
+ break;
+ case'V':
+ $avs=(($date[6]==6)?0:$date[6]+1)-($doy%7);
+ if($avs<0)$avs+=7;
+ $num=(int)(($doy+$avs)/7);
+ if($avs<4){
+ $num++;
+ }elseif($num<1){
+ $num=($avs==4 or $avs==((((($j_y%33)%4)-2)==((int)(($j_y%33)*0.05)))?5:4))?53:52;
+ }
+ $aks=$avs+$kab;
+ if($aks==7)$aks=0;
+ $out.=(($kab+363-$doy)<$aks and $aks<3)?'01':(($num<10)?'0'.$num:$num);
+ break;
+ case'W':
+ $avs=(($date[6]==6)?0:$date[6]+1)-($doy%7);
+ if($avs<0)$avs+=7;
+ $num=(int)(($doy+$avs)/7)+1;
+ if($avs>3)$num--;
+ $out.=($num<10)?'0'.$num:$num;
+ break;
+ /* Month */
+ case'b':
+ case'h':
+ $out.=$this->jdate_words(array('km'=>$j_m),' ');
+ break;
+ case'B':
+ $out.=$this->jdate_words(array('mm'=>$j_m),' ');
+ break;
+ case'm':
+ $out.=($j_m>9)?$j_m:'0'.$j_m;
+ break;
+ /* Year */
+ case'C':
+ $tmp=(int)($j_y/100);
+ $out.=($tmp>9)?$tmp:'0'.$tmp;
+ break;
+ case'g':
+ $jdw=($date[6]==6)?0:$date[6]+1;
+ $dny=364+$kab-$doy;
+ $out.=substr(($jdw>($doy+3) and $doy<3)?$j_y-1:(((3-$dny)>$jdw and $dny<3)?$j_y+1:$j_y),2,2);
+ break;
+ case'G':
+ $jdw=($date[6]==6)?0:$date[6]+1;
+ $dny=364+$kab-$doy;
+ $out.=($jdw>($doy+3) and $doy<3)?$j_y-1:(((3-$dny)>$jdw and $dny<3)?$j_y+1:$j_y);
+ break;
+ case'y':
+ $out.=substr($j_y,2,2);
+ break;
+ case'Y':
+ $out.=$j_y;
+ break;
+ /* Time */
+ case'H':
+ $out.=$date[1];
+ break;
+ case'I':
+ $out.=$date[0];
+ break;
+ case'l':
+ $out.=($date[0]>9)?$date[0]:' '.(int)$date[0];
+ break;
+ case'M':
+ $out.=$date[2];
+ break;
+ case'p':
+ $out.=($date[1]<12)?'قبل از ظهر':'بعد از ظهر';
+ break;
+ case'P':
+ $out.=($date[1]<12)?'ق.ظ':'ب.ظ';
+ break;
+ case'r':
+ $out.=$date[0].':'.$date[2].':'.$date[5].' '.(($date[1]<12)?'قبل از ظهر':'بعد از ظهر');
+ break;
+ case'R':
+ $out.=$date[1].':'.$date[2];
+ break;
+ case'S':
+ $out.=$date[5];
+ break;
+ case'T':
+ $out.=$date[1].':'.$date[2].':'.$date[5];
+ break;
+ case'X':
+ $out.=$date[0].':'.$date[2].':'.$date[5];
+ break;
+ case'z':
+ $out.=date('O',$ts);
+ break;
+ case'Z':
+ $out.=date('T',$ts);
+ break;
+ /* Time and Date Stamps */
+ case'c':
+ $key=$this->jdate_words(array('rh'=>$date[6],'mm'=>$j_m));
+ $out.=$date[1].':'.$date[2].':'.$date[5].' '.date('P',$ts).' '.$key['rh'].'، '.$j_d.' '.$key['mm'].' '.$j_y;
+ break;
+ case'D':
+ $out.=substr($j_y,2,2).'/'.(($j_m>9)?$j_m:'0'.$j_m).'/'.(($j_d<10)?'0'.$j_d:$j_d);
+ break;
+ case'F':
+ $out.=$j_y.'-'.(($j_m>9)?$j_m:'0'.$j_m).'-'.(($j_d<10)?'0'.$j_d:$j_d);
+ break;
+ case's':
+ $out.=$ts;
+ break;
+ case'x':
+ $out.=substr($j_y,2,2).'/'.(($j_m>9)?$j_m:'0'.$j_m).'/'.(($j_d<10)?'0'.$j_d:$j_d);
+ break;
+ /* Miscellaneous */
+ case'n':
+ $out.="\n";
+ break;
+ case't':
+ $out.="\t";
+ break;
+ case'%':
+ $out.='%';
+ break;
+ default:$out.=$sub;
+ }
+ }
+ return($tr_num!='en')?tr_num($out,'fa','.'):$out;
+ }
+ /* F */
+ public function jmktime($h='',$m='',$s='',$jm='',$jd='',$jy='',$none='',$timezone='Asia/Tehran'){
+ if($timezone!='local')date_default_timezone_set($timezone);
+ if($h===''){
+ return time();
+ }else{
+ list($h,$m,$s,$jm,$jd,$jy)=explode('_',$this->tr_num($h.'_'.$m.'_'.$s.'_'.$jm.'_'.$jd.'_'.$jy));
+ if($m===''){
+ return mktime($h);
+ }else{
+ if($s===''){
+ return mktime($h,$m);
+ }else{
+ if($jm===''){
+ return mktime($h,$m,$s);
+ }else{
+ $jdate=explode('_',$this->jdate('Y_j','','',$timezone,'en'));
+ if($jd===''){
+ list($gy,$gm,$gd)=$this->jalali_to_gregorian($jdate[0],$jm,$jdate[1]);
+ return mktime($h,$m,$s,$gm);
+ }else{
+ if($jy===''){
+ list($gy,$gm,$gd)=$this->jalali_to_gregorian($jdate[0],$jm,$jd);
+ return mktime($h,$m,$s,$gm,$gd);
+ }else{
+ list($gy,$gm,$gd)=$this->jalali_to_gregorian($jy,$jm,$jd);
+ return mktime($h,$m,$s,$gm,$gd,$gy);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ /* F */
+ public function jgetdate($timestamp='',$none='',$timezone='Asia/Tehran',$tn='en'){
+ $ts=($timestamp==='')?time():$this->tr_num($timestamp);
+ $jdate=explode('_',jdate('F_G_i_j_l_n_s_w_Y_z',$ts,'',$timezone,$tn));
+ return array(
+ 'seconds'=>$this->tr_num((int)$this->tr_num($jdate[6]),$tn),
+ 'minutes'=>$this->tr_num((int)$this->tr_num($jdate[2]),$tn),
+ 'hours'=>$jdate[1],
+ 'mday'=>$jdate[3],
+ 'wday'=>$jdate[7],
+ 'mon'=>$jdate[5],
+ 'year'=>$jdate[8],
+ 'yday'=>$jdate[9],
+ 'weekday'=>$jdate[4],
+ 'month'=>$jdate[0],
+ 0=>$this->tr_num($ts,$tn)
+ );
+ }
+ /* F */
+ public function jcheckdate($jm,$jd,$jy){
+ list($jm,$jd,$jy)=explode('_',$this->tr_num($jm.'_'.$jd.'_'.$jy));
+ $l_d=($jm==12)?((((($jy%33)%4)-1)==((int)(($jy%33)*0.05)))?30:29):31-(int)($jm/6.5);
+ return($jm>12 or $jd>$l_d or $jm<1 or $jd<1 or $jy<1)?false:true;
+ }
+ /* F */
+ public function tr_num($str,$mod='en',$mf='٫'){
+ $num_a=array('0','1','2','3','4','5','6','7','8','9','.');
+ $key_a=array('۰','۱','۲','۳','۴','۵','۶','۷','۸','۹',$mf);
+ return($mod=='fa')?str_replace($num_a,$key_a,$str):str_replace($key_a,$num_a,$str);
+ }
+ /* F */
+ public function jdate_words($array,$mod=''){
+ foreach($array as $type=>$num){
+ $num=(int)$this->tr_num($num);
+ switch($type){
+ case'ss':
+ $sl=strlen($num);
+ $xy3=substr($num,2-$sl,1);
+ $h3=$h34=$h4='';
+ if($xy3==1){
+ $p34='';
+ $k34=array('ده','یازده','دوازده','سیزده','چهارده','پانزده','شانزده','هفده','هجده','نوزده');
+ $h34=$k34[substr($num,2-$sl,2)-10];
+ }else{
+ $xy4=substr($num,3-$sl,1);
+ $p34=($xy3==0 or $xy4==0)?'':' و ';
+ $k3=array('','','بیست','سی','چهل','پنجاه','شصت','هفتاد','هشتاد','نود');
+ $h3=$k3[$xy3];
+ $k4=array('','یک','دو','سه','چهار','پنج','شش','هفت','هشت','نه');
+ $h4=$k4[$xy4];
+ }
+ $array[$type]=(($num>99)?str_replace(array('12','13','14','19','20')
+ ,array('هزار و دویست','هزار و سیصد','هزار و چهارصد','هزار و نهصد','دوهزار')
+ ,substr($num,0,2)).((substr($num,2,2)=='00')?'':' و '):'').$h3.$p34.$h34.$h4;
+ break;
+ case'mm':
+ $key=array('فروردین','اردیبهشت','خرداد','تیر','مرداد','شهریور','مهر','آبان','آذر','دی','بهمن','اسفند');
+ $array[$type]=$key[$num-1];
+ break;
+ case'rr':
+ $key=array('یک','دو','سه','چهار','پنج','شش','هفت','هشت','نه','ده','یازده','دوازده','سیزده'
+ ,'چهارده','پانزده','شانزده','هفده','هجده','نوزده','بیست','بیست و یک','بیست و دو','بیست و سه'
+ ,'بیست و چهار','بیست و پنج','بیست و شش','بیست و هفت','بیست و هشت','بیست و نه','سی','سی و یک');
+ $array[$type]=$key[$num-1];
+ break;
+ case'rh':
+ $key=array('یکشنبه','دوشنبه','سه شنبه','چهارشنبه','پنجشنبه','جمعه','شنبه');
+ $array[$type]=$key[$num];
+ break;
+ case'sh':
+ $key=array('مار','اسب','گوسفند','میمون','مرغ','سگ','خوک','موش','گاو','پلنگ','خرگوش','نهنگ');
+ $array[$type]=$key[$num%12];
+ break;
+ case'mb':
+ $key=array('حمل','ثور','جوزا','سرطان','اسد','سنبله','میزان','عقرب','قوس','جدی','دلو','حوت');
+ $array[$type]=$key[$num-1];
+ break;
+ case'ff':
+ $key=array('بهار','تابستان','پاییز','زمستان');
+ $array[$type]=$key[(int)($num/3.1)];
+ break;
+ case'km':
+ $key=array('فر','ار','خر','تی','مر','شه','مه','آب','آذ','دی','به','اس');
+ $array[$type]=$key[$num-1];
+ break;
+ case'kh':
+ $key=array('ی','د','س','چ','پ','ج','ش');
+ $array[$type]=$key[$num];
+ break;
+ default:$array[$type]=$num;
+ }
+ }
+ return($mod==='')?$array:implode($mod,$array);
+ }
+ /** Gregorian & Jalali (Hijri_Shamsi,Solar) date converter Functions
+ Author: JDF.SCR.IR =>> Download Full Version : http://jdf.scr.ir/jdf
+ License: GNU/LGPL _ Open Source & Free _ Version: 2.70 : [2017=1395]
+ --------------------------------------------------------------------
+ 1461 = 365*4 + 4/4 & 146097 = 365*400 + 400/4 - 400/100 + 400/400
+ 12053 = 365*33 + 32/4 & 36524 = 365*100 + 100/4 - 100/100 */
+ /* F */
+ public function gregorian_to_jalali($gy,$gm,$gd,$mod=''){
+ list($gy,$gm,$gd)=explode('_',$this->tr_num($gy.'_'.$gm.'_'.$gd));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */
+ $g_d_m=array(0,31,59,90,120,151,181,212,243,273,304,334);
+ if($gy > 1600){
+ $jy=979;
+ $gy-=1600;
+ }else{
+ $jy=0;
+ $gy-=621;
+ }
+ $gy2=($gm > 2)?($gy+1):$gy;
+ $days=(365*$gy) +((int)(($gy2+3)/4)) -((int)(($gy2+99)/100)) +((int)(($gy2+399)/400)) -80 +$gd +$g_d_m[$gm-1];
+ $jy+=33*((int)($days/12053));
+ $days%=12053;
+ $jy+=4*((int)($days/1461));
+ $days%=1461;
+ $jy+=(int)(($days-1)/365);
+ if($days > 365)$days=($days-1)%365;
+ if($days < 186){
+ $jm=1+(int)($days/31);
+ $jd=1+($days%31);
+ }else{
+ $jm=7+(int)(($days-186)/30);
+ $jd=1+(($days-186)%30);
+ }
+ return($mod==='')?array($jy,$jm,$jd):$jy .$mod .$jm .$mod .$jd;
+ }
+ /* F */
+ public function jalali_to_gregorian($jy,$jm,$jd,$mod=''){
+ list($jy,$jm,$jd)=explode('_',$this->tr_num($jy.'_'.$jm.'_'.$jd));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */
+ if($jy > 979){
+ $gy=1600;
+ $jy-=979;
+ }else{
+ $gy=621;
+ }
+ $days=(365*$jy) +(((int)($jy/33))*8) +((int)((($jy%33)+3)/4)) +78 +$jd +(($jm<7)?($jm-1)*31:(($jm-7)*30)+186);
+ $gy+=400*((int)($days/146097));
+ $days%=146097;
+ if($days > 36524){
+ $gy+=100*((int)(--$days/36524));
+ $days%=36524;
+ if($days >= 365)$days++;
+ }
+ $gy+=4*((int)(($days)/1461));
+ $days%=1461;
+ $gy+=(int)(($days-1)/365);
+ if($days > 365)$days=($days-1)%365;
+ $gd=$days+1;
+ foreach(array(0,31,((($gy%4==0) and ($gy%100!=0)) or ($gy%400==0))?29:28 ,31,30,31,30,31,31,30,31,30,31) as $gm=>$v){
+ if($gd <= $v)break;
+ $gd-=$v;
+ }
+ return($mod==='')?array($gy,$gm,$gd):$gy .$mod .$gm .$mod .$gd;
+ }
+
+ public function pastTime($time): string
+ {
+
+ $time = time() - $time; // to get the time since that moment
+ $tokens = array (
+ 31536000 => 'سال',
+ 2592000 => 'ماه',
+ 604800 => 'هفته',
+ 86400 => 'روز',
+ 3600 => 'ساعت',
+ 60 => 'دقیقه',
+ 1 => 'ثانیه'
+ );
+ foreach ($tokens as $unit => $text) {
+ if ($time < $unit) continue;
+ $numberOfUnits = floor($time / $unit);
+ return $numberOfUnits.' '.$text . ' قبل ';
+ }
+ return 'چند ثانیه قبل';
+ }
+}
\ No newline at end of file
diff --git a/src/Service/Provider.php b/src/Service/Provider.php
new file mode 100644
index 0000000..f125eb5
--- /dev/null
+++ b/src/Service/Provider.php
@@ -0,0 +1,39 @@
+getContent()) {
+ $params = json_decode($content, true);
+ }
+
+ //set page of content want to search
+ $page = 1;
+ if(array_key_exists('page',$params))
+ $page = $params['page'];
+ $response['page'] = $page;
+
+ //set max Count of content want to search
+ $count = 30;
+ if(array_key_exists('count',$params))
+ $count = $params['count'];
+ $response['count'] = $count;
+
+ //set search keyword of content
+ $search = '';
+ if(array_key_exists('key',$params))
+ $search = $params['key'];
+ $response['key'] = $search;
+
+ return $response;
+ }
+ public function gravatarHash($email){
+ return md5( strtolower( trim( $email) ) );
+ }
+}
\ No newline at end of file
diff --git a/symfony.lock b/symfony.lock
index ad9e6d8..14e5788 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -1,4 +1,13 @@
{
+ "doctrine/annotations": {
+ "version": "1.14",
+ "recipe": {
+ "repo": "github.com/symfony/recipes",
+ "branch": "main",
+ "version": "1.10",
+ "ref": "64d8583af5ea57b7afa4aba4b159907f3a148b05"
+ }
+ },
"doctrine/doctrine-bundle": {
"version": "2.8",
"recipe": {