本文整理汇总了PHP中CFileHelper::createDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP CFileHelper::createDirectory方法的具体用法?PHP CFileHelper::createDirectory怎么用?PHP CFileHelper::createDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileHelper
的用法示例。
在下文中一共展示了CFileHelper::createDirectory方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->mockApplication(['components' => ['mailer' => ['class' => 'bashkarev\\swiftmailer\\swift\\Mailer', 'useFileTransport' => true]]]);
$filePath = $this->getTestFilePath();
if (!file_exists($filePath)) {
FileHelper::createDirectory($filePath);
}
}
示例2: afterInstall
public function afterInstall()
{
Yii::app()->settings->set('shop', SettingsShopForm::defaultSettings());
Yii::app()->database->import($this->id);
Yii::app()->widgets->set('system', array('alias_wgt' => 'mod.shop.blocks.popular.PopularBlock', 'name' => 'Поп товары'));
Yii::app()->widgets->set('module', array('alias_wgt' => 'mod.shop.blocks.search.SearchWidget', 'name' => 'Поиск товаров'));
CFileHelper::createDirectory(Yii::getPathOfAlias('webroot.uploads.product'), 0777);
CFileHelper::createDirectory(Yii::getPathOfAlias('webroot.uploads.manufacturer'), 0777);
CFileHelper::createDirectory(Yii::getPathOfAlias('webroot.uploads.categories'), 0777);
Yii::app()->intallComponent('currency', 'mod.shop.components.CurrencyManager');
return parent::afterInstall();
}
示例3: actionIndex
public function actionIndex()
{
$dir = Yii::getPathOfAlias('webroot') . '/uploads/partner/';
CFileHelper::removeDirectory($dir);
if (is_dir($dir) == false) {
CFileHelper::createDirectory($dir, Yii::app()->params['storeImages']['dirMode']);
}
$dir = Yii::getPathOfAlias('webroot') . '/assets/thumbs/';
CFileHelper::removeDirectory($dir);
if (is_dir($dir) == false) {
CFileHelper::createDirectory($dir, Yii::app()->params['storeImages']['dirMode']);
}
}
示例4: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
Yii::app()->mailer->attachEventHandler(BaseMailer::EVENT_AFTER_SEND, function ($event) {
/* @var $message MessageInterface */
$message = $event->params['message'];
$messageData = ['isSuccessful' => $event->params['isSuccessful'], 'from' => $this->convertParams($message->getFrom()), 'to' => $this->convertParams($message->getTo()), 'reply' => $this->convertParams($message->getReplyTo()), 'cc' => $this->convertParams($message->getCc()), 'bcc' => $this->convertParams($message->getBcc()), 'subject' => $message->getSubject(), 'charset' => $message->getCharset()];
// add more information when message is a SwiftMailer message
if ($message instanceof \bashkarev\swiftmailer\swift\Message) {
/* @var $swiftMessage \Swift_Message */
$swiftMessage = $message->getSwiftMessage();
$body = $swiftMessage->getBody();
if (empty($body)) {
$parts = $swiftMessage->getChildren();
foreach ($parts as $part) {
if (!$part instanceof \Swift_Mime_Attachment) {
/* @var $part \Swift_Mime_MimePart */
if ($part->getContentType() == 'text/plain') {
$messageData['charset'] = $part->getCharset();
$body = $part->getBody();
break;
}
}
}
}
$messageData['body'] = $body;
$messageData['time'] = $swiftMessage->getDate();
$messageData['headers'] = $swiftMessage->getHeaders();
}
// store message as file
$fileName = $event->sender->generateMessageFileName();
$path = Yii::getPathOfAlias($this->mailPath);
if (!is_dir($path)) {
\CFileHelper::createDirectory($path);
}
file_put_contents($path . '/' . $fileName, $message->toString());
$messageData['file'] = $fileName;
$this->_messages[] = $messageData;
});
}
示例5: getFolderPath
protected function getFolderPath()
{
$dir = Yii::getPathOfAlias(Yii::app()->params['storeImages']['uploads']) . DIRECTORY_SEPARATOR . $this->ownerName . DIRECTORY_SEPARATOR . $this->owner->id;
if (is_dir($dir) == false) {
CFileHelper::createDirectory($dir, Yii::app()->params['storeImages']['dirMode'], true);
}
return $dir;
}
示例6: getFolderPath
/**
* get the path folder of the stored files
*/
protected function getFolderPath()
{
$dir = Yii::getPathOfAlias('webroot') . DIRECTORY_SEPARATOR . $this->relativeWebRootFolder;
if ($this->relativeWebRootFolderModel) {
$dir .= DIRECTORY_SEPARATOR . $this->relativeWebRootFolderModel;
}
if ($this->owner->id) {
$dir .= DIRECTORY_SEPARATOR . $this->owner->id;
}
if (is_dir($dir) == false) {
CFileHelper::createDirectory($dir, Yii::app()->params['storeImages']['dirMode']);
}
return $dir;
}
示例7: getFileFolder
public function getFileFolder()
{
$dir = Yii::getPathOfAlias('webroot') . '/uploads/user/' . $this->id . '/';
if (is_dir($dir) == false) {
CFileHelper::createDirectory($dir, Yii::app()->params['storeImages']['dirMode']);
}
return $dir;
}
示例8: testCreateDirectory
public function testCreateDirectory()
{
$path = $this->testDir . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'path';
$this->assertTrue(CFileHelper::createDirectory($path, null, true));
$this->assertTrue(is_dir($path));
}
示例9: getUrl
/**
* Get url to product image. Enter $size to resize image.
* @param mixed $size New size of the image. e.g. '150x150'
* @param mixed $resizeMethod Resize method name to override config. resize/adaptiveResize
* @param mixed $random Add random number to the end of the string
* @return string
*/
public function getUrl($subfolder = '', $id, $size = false, $resizeMethod = false, $random = false)
{
// Path to source image
$fullPath = Yii::getPathOfAlias(FileImageConfig::get('path'));
if($subfolder)
$fullPath .= '/'.$subfolder.'/';
if($id)
$fullPath .= '/'.$id;
$fullPath .= '/'.$this->id_photo.'.'.$this->extention;
if($size !== false)
{
//$thumbPath = Yii::getPathOfAlias(Yii::app()->params['storeImages']['thumbPath']).'/'.$size;
$thumbPath = Yii::getPathOfAlias(FileImageConfig::get('thumbPath')).'/'.$size;
if(!file_exists($thumbPath)){
CFileHelper:: createDirectory($thumbPath, Yii::app()->params['storeImages']['dirMode']);
}
// Path to thumb
$thumbPath = $thumbPath.'/'.$this->id_photo.'.'.$this->extention;
if(!file_exists($fullPath)){
return false;
}
if(!file_exists($thumbPath) && file_exists($fullPath))
{
// Resize if needed
Yii::import('ext.phpthumb.PhpThumbFactory');
$sizes = explode('x', $size);
$thumb = PhpThumbFactory::create($fullPath);
if($resizeMethod === false)
$resizeMethod = FileImageConfig::get('resizeThumbMethod');
if(!empty($sizes[1])){
$thumb->$resizeMethod($sizes[0],$sizes[1])->save($thumbPath);
} else {
$thumb->$resizeMethod($size)->save($thumbPath);
}
}
return ImagesConfig::get('thumbUrl').$size.'/'.$this->id_photo.'.'.$this->extention;
}
if ($random === true){
return $fullPath.'?'.rand(1, 10000);
}
return $fullPath;
}
示例10: mkdir
static function mkdir($dir, $mode = 0777, $recursive = false)
{
if (!is_dir($dir)) {
CFileHelper::createDirectory($dir, $mode, $recursive);
}
}