TYPO3 file upload resource manager - file-upload

I made file upload according to http://docs.typo3.org/flow/TYPO3FlowDocumentation/TheDefinitiveGuide/PartIII/ResourceManagement.html
I have this error: Invalid type encountered: '\TYPO3\Flow\Resource\Resource'
Code
Controler:
class Tx_PromConf_Controller_RegistrationController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* Imports a passport
*
* #param Tx_PromConf_Domain_Model_Passport $passport The new passport
* #return void
*/
public function passportUploadAction(Tx_PromConf_Domain_Model_Passport $passport) {
$this->passportRepository->add($passport);
$this->forward('index');
}
}
Model
class Tx_PromConf_Domain_Model_Passport extends Tx_Extbase_DomainObject_AbstractEntity {
/**
* #var string
*/
protected $title;
/**
* #var \TYPO3\Flow\Resource\Resource
*/
protected $originalResource;
/**
* #param string $title
* #return void
*/
public function setTitle($title) {
$this->title = $title;
}
/**
* #return string
*/
public function getTitle() {
return $this->title;
}
/**
* #param \TYPO3\Flow\Resource\Resource $originalResource
* #return void
*/
public function setOriginalResource(\TYPO3\Flow\Resource\Resource $originalResource) {
$this->originalResource = $originalResource;
}
/**
* #return \TYPO3\Flow\Resource\Resource
*/
public function getOriginalResource() {
return $this->originalResource;
}
/**
* __construct
*
* #return void
*/
public function __construct() {
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
$this->setTitle('PassportScan');
}
/**
* Initializes all Tx_Extbase_Persistence_ObjectStorage properties.
*
* #return void
*/
protected function initStorageObjects() {
}
}
Form
<f:form action="passportUpload" controller="Registration" enctype="multipart/form-data"
object="{passport}" objectName="passport">
<br />
<div>
<f:translate key="tx_promconf_passport_upload.sentense" />
</div>
<br />
<div class="max-size">
<f:form.upload class="btn" name="originalResource" />
</div>
<br />
<br />
<div class="max-size">
<f:form.submit name="mySubmit" class="btn btn-l" value="<f:translate key='tx_promconf_passport_upload.ok' />" />
<input type="reset" class="btn btn-r" value="<f:translate key='tx_promconf_passport_upload.cancel' />" />
</div>
</f:form>

In case you are using TYPO3 CMS:
You will not find the class TYPO3\Flow\Resource\Resource there.
Therefore you are bound to Extbase classes. If you are using TYPO3 6.x, you might want to look either in the Extbase namespace or somewhere here: \TYPO3\CMS\Core\Resource\ResourceInterface.
But most probably, the easiest way is to look for another tutorial on file uploads with Extbase.
If you're developing a standalone FLOW application, I don't have a precise answer.

Related

Issue With Laravel 8 Auth Email Verification

I'm Using Laravel 8.x And i'm trying to make login/register With Email verification
I followed Some Tutorials,Blogs but didn't get desired output
I want:-
Whenever User Register themselve An Verification Email must send to there email
(Email Is Sent but not able to verify by that url so i follow some laracast blog by that i'm able to verify by that verification url)
but the issue is if i didn't verified my self i'm still able to login into my application
Here Is Codes
HomeController
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* #return void
*/
public function __construct()
{
$this->middleware(['auth','verified']);
}
/**
* Show the application dashboard.
*
* #return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}
Register Controller
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller
{
/*
','--------------------------------------------------------------------------
',' Register Controller
','--------------------------------------------------------------------------
','
',' This controller handles the registration of new users as well as their
',' validation and creation. By default this controller uses a trait to
',' provide this functionality without requiring any additional code.
','
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* #var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* #return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* #param array $data
* #return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'contact' => ['required','min:10'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required','string','min:8','confirmed','regex:/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!#$%^&*-]).{6,}$/'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* #param array $data
* #return \App\Models\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'contact' => $data['contact'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}
Veification Controller
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;
use Illuminate\Http\Request;
use Illuminate\Auth\Events\Verified;
use Illuminate\Auth\Access\AuthorizationException;
use App\Models\User;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* #var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* #return void
*/
public function __construct()
{
// $this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
public function verify(Request $request)
{
// if ($request->route('id') != $request->user()->getKey()) {
// throw new AuthorizationException;
// }
$user = User::find($request->route('id'));
auth()->login($user);
if ($request->user()->hasVerifiedEmail()) {
return redirect($this->redirectPath());
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}
return redirect($this->redirectPath())->with('verified', true);
}
}
Route
Auth::routes(['verify' => true]);
Route::group(['prefix'=>'user', 'middleware' => 'auth'],function(){});

How to override Model in Sylius 1.4

I want to add new field (type) on Customer in Sylius 1.4
I use doc to override Model, but it's not working.
src\Entity\Customer\Customer.php
<?php
declare(strict_types=1);
namespace App\Entity\Customer;
use Doctrine\ORM\Mapping\MappedSuperclass;
use Doctrine\ORM\Mapping\Table;
use Sylius\Component\Core\Model\Customer as BaseCustomer;
/**
* #MappedSuperclass
* #Table(name="sylius_customer")
*/
class Customer extends BaseCustomer
{
/** #var string */
protected $type = 'i';
/**
* {#inheritdoc}
*/
public function getType(): string
{
return $this->type;
}
/**
* {#inheritdoc}
*/
public function setType(?string $type): void
{
$this->type = $type;
}
}
src\Resources\config\doctrine\Customer.orm.xml
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="App\Entity\Customer" table="sylius_customer">
<field name="type" column="type" type="string" length="1">
<options>
<option name="default">i</option>
</options>
</field>
</mapped-superclass>
</doctrine-mapping>
config\packages\_sylius.yaml (no change)
sylius_customer:
resources:
customer:
classes:
model: App\Entity\Customer\Customer
Finally, use : php bin/console make:migration
[WARNING] No database changes were detected.
The database schema and the application mapping information are already in sync.
What is false ?
Try to change #MappedSuperclass in class definition to #Entity. If doesn't work, in Customer.orm.xml change mapped-superclass to entity
I think you need to implement the CustomerInterface
use Doctrine\ORM\Mapping\MappedSuperclass;
use Doctrine\ORM\Mapping\Table;
use Sylius\Component\Core\Model\Customer as BaseCustomer;
use Sylius\Component\Core\Model\CustomerInterface;
/**
* #MappedSuperclass
* #Table(name="sylius_customer")
*/
class Customer extends BaseCustomer implements CustomerInterface
{
/*...*/

Laravel "auth controller not found" exception

I am making admin panel in LARAVEL4.2.*. I make the controller in "admin" folder and also a view in views "admin" folder. My controller code is
namespace admin;
class AuthController extends \BaseController {
/**
* Display a listing of the resource.
*
* #return Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* #return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* #return Response
*/
public function store()
{
//
}
/**
* Display the specified resource.
*
* #param int $id
* #return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* #param int $id
* #return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* #param int $id
* #return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
*
* #param int $id
* #return Response
*/
public function destroy($id)
{
//
}
}
and my routes coding is:
Route::get('admin/login', array('as' => 'admin.login', 'uses' => 'App\Controllers\Admin\AuthController#getLogin'));
I have also tried "composer update" and "composer dump-autoload" above 50 times. My url is localhost/laraveltest/public/admin/login.
You defined your namespace as admin, therefore you have to use this also in your routes:
Route::get('admin/login', array('uses' => '\admin\AuthController#getLogin'));

When I use a function that I append to the class Controller, it does not work in Yii

I appended a xxx function to the class Controller, then I touched a file named 'VideoController'. It's extends Controller.
When I execute the VideoController, the xxx function can't be called, why?
the function ajaxReturn :
class Controller extends CController
{
/**
* #var string the default layout for the controller view. Defaults to '//layouts/column1',
* meaning using a single column layout. See 'protected/views/layouts/column1.php'.
*/
public $layout='//layouts/column1';
/**
* #var array context menu items. This property will be assigned to {#link CMenu::items}.
*/
public $menu=array();
/**
* #var array the breadcrumbs of the current page. The value of this property will
* be assigned to {#link CBreadcrumbs::links}. Please refer to {#link CBreadcrumbs::links}
* for more details on how to specify this property.
*/
public $breadcrumbs=array();
/**
* zhoumengkang
* 从Thinkphp里拖过来的
*/
protected function ajaxReturn($data,$info='',$status=1,$type='JSON') {
$result = array();
$result['status'] = $status;
$result['info'] = $info;
$result['data'] = $data;
if(strtoupper($type)=='JSON') {
header("Content-Type:text/html; charset=utf-8");
exit(json_encode($result));
}elseif(strtoupper($type)=='XML'){
header("Content-Type:text/xml; charset=utf-8");
exit(xml_encode($result));
}elseif(strtoupper($type)=='EVAL'){
header("Content-Type:text/html; charset=utf-8");
exit($data);
}else{
// TODO
}
}
}
but it can't by called in
class VideoController extends Controller {
public function actionTest() {
$this->ajaxReturn(true,'test',1);
}
}
You have to import your controller before extend.
Yii::import('application.controllers.Controller');
class VideoController extends Controller {
public function actionTest() {
$this->ajaxReturn(true,'test',1);
}
}
Better change your controller name from Controller to someothername.

How to store priority in a Many-to-Many relationship with Doctrine 2.0

My problem is simple:
I have Users and Stories in a many to many relationship, I would like to store a couple of attribute in the UserStory relationship:
Priority (In order to set the ordering of the display for a given user)
Main (flags which one is the main story)
How can I do that ?
Let say we have the following :
<?php
/** #Entity */
class User
{
// ...
/**
* #ManyToMany(targetEntity="Story", inversedBy="users")
* #JoinTable(name="users_stories")
*/
private $stories;
public function __construct() {
$this->stories = new \Doctrine\Common\Collections\ArrayCollection();
}
// ...
}
/** #Entity */
class Story
{
// ...
/**
* #ManyToMany(targetEntity="User", mappedBy="stories")
*/
private $users;
public function __construct() {
$this->users = new \Doctrine\Common\Collections\ArrayCollection();
}
// ...
}
?>
As Crozin suggested, this question is a duplicate of:
Doctrine2: Best way to handle many-to-many with extra columns in reference table
In my specific case the solution is simple. The Many-To-Many relationship needs to be build by hand, and extra fields need to be added manually. So two OneToMany relationship need to be build.
So here are my 3 objects and the associated meta information for each attribute:
<?php
/**
* #Entity
* #Table(name="users")
*/
class User{
/**
* #Id
* #Column(type="integer", name="id")
* #GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #OneToMany(targetEntity="UserStory", mappedBy="user")
*/
private $user_stories;
// ...
}
/**
* #Entity
* #Table(name="user_stories")
*/
class UserStory{
/**
* #Id
* #Column(type="integer", name="id")
* #GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #ManyToOne(targetEntity="User", inversedBy="user_stories")
*/
private $user;
/**
* #ManyToOne(targetEntity="Story", inversedBy="user_stories")
*/
private $stories;
/**
* #Column(type="integer")
*/
private $priority;
/**
* #Column(type="integer")
*/
private $priority_tmp;
/**
* #Column(type="integer")
*/
private $main;
// ...
}
/**
* #Entity
* #Table(name="stories")
*/
class Story
{
/**
* #Id
* #Column(type="integer", name="id")
* #GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #OneToMany(targetEntity="UserStory", mappedBy="stories")
*/
private $user_stories;
// ...
}
?>